Let IMAP scanner accept null

The IMAP scanner does not accept non-existing input strings. The problem
is that it has to compute the length of the string and this fails if the
string is null.

Check that the string is non-null before computing the length of it and
just set it to zero if it's null. The actual scanning is done withing
this boundary and it will not attempt to do any scanning if the length
is zero.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>