From 0096298d5c33643154ae21c7dd4493336bf07f10 Mon Sep 17 00:00:00 2001 From: edwardmbsmith <44281784+edwardmbsmith@users.noreply.github.com> Date: Fri, 21 Jun 2019 12:52:33 +0800 Subject: [PATCH 1/3] Update imaplib.py to account for additional padding Regex for imaplib should account for IMAP servers which return one or two whitespaces after the * in responses. Updated the regex check to account for this --- Lib/imaplib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/imaplib.py b/Lib/imaplib.py index 341ee25ae96514..e7833ae0ae8d96 100644 --- a/Lib/imaplib.py +++ b/Lib/imaplib.py @@ -124,7 +124,7 @@ Untagged_response = re.compile(br'\* (?P[A-Z-]+)( (?P.*))?') # Untagged_status is no longer used; kept for backward compatibility Untagged_status = re.compile( - br'\* (?P\d+) (?P[A-Z-]+)( (?P.*))?', re.ASCII) + br'\*[ ]{1,2}(?P\d+) (?P[A-Z-]+)( (?P.*))?', re.ASCII) # We compile these in _mode_xxx. _Literal = br'.*{(?P\d+)}$' _Untagged_status = br'\* (?P\d+) (?P[A-Z-]+)( (?P.*))?' From 03e06f2f460b9b3d52b3ac0c319f3ab67af4db3d Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Wed, 26 Jun 2019 06:12:10 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2019-06-26-06-12-08.bpo-37407.Qc1pW1.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2019-06-26-06-12-08.bpo-37407.Qc1pW1.rst diff --git a/Misc/NEWS.d/next/Library/2019-06-26-06-12-08.bpo-37407.Qc1pW1.rst b/Misc/NEWS.d/next/Library/2019-06-26-06-12-08.bpo-37407.Qc1pW1.rst new file mode 100644 index 00000000000000..1249f15acb6df0 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-06-26-06-12-08.bpo-37407.Qc1pW1.rst @@ -0,0 +1,19 @@ +Found the response of the `EXISTS` command is padded by some IMAP servers/translators including `davmail`, it seems to be when the number of emails is around or over 500. + +Acceptable response: +``` + 58:24.54 > PJJD3 EXAMINE INBOX + 58:24.77 < * 486 EXISTS + 58:24.78 matched r'\* (?P\d+) (?P[A-Z-]+)( (?P.*))?' => ('486', 'EXISTS', None, None) + 58:24.78 untagged_responses[EXISTS] 0 += ["486"] +``` +Failed response: +``` + 57:50.86 > KPFE3 EXAMINE INBOX + 57:51.10 < * 953 EXISTS + 57:51.10 last 0 IMAP4 interactions: + 57:51.10 > KPFE4 LOGOUT +``` +Notice the additional whitespace after the * + +The `imaplib` default regex should be updated to account for one or two whitespaces \ No newline at end of file From 760b40a9cb5b6530f0e90546b70c8589f92f3af0 Mon Sep 17 00:00:00 2001 From: edwardmbsmith <44281784+edwardmbsmith@users.noreply.github.com> Date: Wed, 26 Jun 2019 14:31:39 +0800 Subject: [PATCH 3/3] Update 2019-06-26-06-12-08.bpo-37407.Qc1pW1.rst --- .../2019-06-26-06-12-08.bpo-37407.Qc1pW1.rst | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/Misc/NEWS.d/next/Library/2019-06-26-06-12-08.bpo-37407.Qc1pW1.rst b/Misc/NEWS.d/next/Library/2019-06-26-06-12-08.bpo-37407.Qc1pW1.rst index 1249f15acb6df0..3a8af6aa37b9ad 100644 --- a/Misc/NEWS.d/next/Library/2019-06-26-06-12-08.bpo-37407.Qc1pW1.rst +++ b/Misc/NEWS.d/next/Library/2019-06-26-06-12-08.bpo-37407.Qc1pW1.rst @@ -1,19 +1,2 @@ -Found the response of the `EXISTS` command is padded by some IMAP servers/translators including `davmail`, it seems to be when the number of emails is around or over 500. - -Acceptable response: -``` - 58:24.54 > PJJD3 EXAMINE INBOX - 58:24.77 < * 486 EXISTS - 58:24.78 matched r'\* (?P\d+) (?P[A-Z-]+)( (?P.*))?' => ('486', 'EXISTS', None, None) - 58:24.78 untagged_responses[EXISTS] 0 += ["486"] -``` -Failed response: -``` - 57:50.86 > KPFE3 EXAMINE INBOX - 57:51.10 < * 953 EXISTS - 57:51.10 last 0 IMAP4 interactions: - 57:51.10 > KPFE4 LOGOUT -``` -Notice the additional whitespace after the * - -The `imaplib` default regex should be updated to account for one or two whitespaces \ No newline at end of file +Allow one or two whitespaces after * in IMAP response. +Patch by Edward Smith.