diff options
author | R David Murray <rdmurray@bitdance.com> | 2016-01-02 22:18:34 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2016-01-02 22:18:34 (GMT) |
commit | 317f64f048b6da8a53870ce6a1d63ad458ece95f (patch) | |
tree | 156ea63eb1509faaa061ba823a10ceda2d65965e /Lib/imaplib.py | |
parent | 01759d55547c4f39d451f4063d51fd309744f3ea (diff) | |
download | cpython-317f64f048b6da8a53870ce6a1d63ad458ece95f.zip cpython-317f64f048b6da8a53870ce6a1d63ad458ece95f.tar.gz cpython-317f64f048b6da8a53870ce6a1d63ad458ece95f.tar.bz2 |
#21815: violate IMAP RFC to be compatible with, e.g., gmail
and others, including imaplib's own behavior. I'm applying this only to 3.6
because there's a potential backward compatibility concern: if there are
servers that include ] characters in the 'text' portion of their imap
responses, this code change could introduce a new bug.
Patch by Lita Cho, reviewed by Jessica McKellar, Berker Peksag, Maciej Szulik,
silentghost, and me (I fleshed out the comments with the additional
info/concerns.)
Diffstat (limited to 'Lib/imaplib.py')
-rw-r--r-- | Lib/imaplib.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/imaplib.py b/Lib/imaplib.py index 4e8a4bb..a63ba8d 100644 --- a/Lib/imaplib.py +++ b/Lib/imaplib.py @@ -111,7 +111,15 @@ InternalDate = re.compile(br'.*INTERNALDATE "' # Literal is no longer used; kept for backward compatibility. Literal = re.compile(br'.*{(?P<size>\d+)}$', re.ASCII) MapCRLF = re.compile(br'\r\n|\r|\n') -Response_code = re.compile(br'\[(?P<type>[A-Z-]+)( (?P<data>[^\]]*))?\]') +# We no longer exclude the ']' character from the data portion of the response +# code, even though it violates the RFC. Popular IMAP servers such as Gmail +# allow flags with ']', and there are programs (including imaplib!) that can +# produce them. The problem with this is if the 'text' portion of the response +# includes a ']' we'll parse the response wrong (which is the point of the RFC +# restriction). However, that seems less likely to be a problem in practice +# than being unable to correctly parse flags that include ']' chars, which +# was reported as a real-world problem in issue #21815. +Response_code = re.compile(br'\[(?P<type>[A-Z-]+)( (?P<data>.*))?\]') Untagged_response = re.compile(br'\* (?P<type>[A-Z-]+)( (?P<data>.*))?') # Untagged_status is no longer used; kept for backward compatibility Untagged_status = re.compile( |