I'm accessing GMail's IMAP interface through python. I run a command like this:
UID SEARCH HEADER Message-ID "abcdef@abc.com"
That succeeds (returns 1 UID of the matching message, or 0 if it doesn't exist). However, if the search-text contains certain chars (like & or !), the search-text is truncated at that point. This means:
UID SEARCH HEADER Message-ID "!abcdef@abc.com"
Is treated the same as
UID SEARCH HEADER Message-ID ""
Also:
UID SEARCH HEADER Message-ID "abc!def@abc.com"
Is treated as:
UID SEARCH HEADER Message-ID "abc"
I've gone through the IMAP language spec, and from the ABNF language spec it seems like those chars should be valid. Why is gmail truncating these search phrases at the "!" and "&" chars? Is there a way to escape them? (I've tried !, fails as a badly-encoded string). Is there an RFC or doc that shows what really should be accepted? Is this a bug in gmail's imap implementation?
I've also tried literal format, same results:
UID SEARCH HEADER Message-ID {15}
abc!def@abc.com
Still treated as:
UID SEARCH HEADER Message-ID {3}
abc
Thanks!
IMAP RFC3501 Search Command: https://www.rfc-editor.org/rfc/rfc3501#section-6.4.4 Formal syntax: https://www.rfc-editor.org/rfc/rfc3501#section-9