I'm accessing GMail's IMAP interface through python. I run a command like this:
UID SEARCH HEADER Message-ID "[email protected]"
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 "[email protected]"
Is treated the same as
UID SEARCH HEADER Message-ID ""
Also:
UID SEARCH HEADER Message-ID "[email protected]"
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}
[email protected]
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
!
. – OdeyX-GM-RAW
extension is documented at developers.google.com/gmail/… , as it was pointed out in https://mcmap.net/q/1470589/-search-utf-8-string-with-gmail-x-gm-raw-imap-command/94687 . – Odeysubject:(!)
correct for searching for subjects containing an exclamation mark? Is there a family ofrfc822*
keys in GMail? – Odey!
in the subject, it seems to not work with any queries in the GMail web interface, too (so, X-GM-RAW wouldn't work, too). See webapps.stackexchange.com/q/31322/15124 , webapps.stackexchange.com/q/52828/15124 . Very inconvenient! So, an exernal IMAP client for such kind of searches is not a solution (unless the client does the filtering itself, without relying on server responses toSEARCH
). – Odey