From 2c5c9681a3e505a272d13687d303abbb8f01e06d Mon Sep 17 00:00:00 2001 From: nick evans Date: Tue, 28 Nov 2023 18:53:54 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Workaround=20buggy=20outlook.com?= =?UTF-8?q?=20address=20lists?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Outlook.com sends an extraneous `SP` in between `address` values in its envelope address lists: `env-{from,sender,reply-to,to,cc,bcc}`. This can't be parsed by the envelope performance tuning rewrite in #232, in the v0.4.6 release. I've had a private test for this quirk for a decade... but the test was primarily testing a different (much stranger) BODYSTRUCTURE bug, so I thought the extra SP was a transcription error and "fixed" the test... Oops! The example comes from a real response, but all addesses have been replaced by the `faker` gem. :) --- lib/net/imap/response_parser.rb | 8 +++++++- .../imap/fixtures/response_parser/quirky_behaviors.yml | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/net/imap/response_parser.rb b/lib/net/imap/response_parser.rb index 2a73f2482..827e2ef94 100644 --- a/lib/net/imap/response_parser.rb +++ b/lib/net/imap/response_parser.rb @@ -978,10 +978,16 @@ def envelope # env-bcc = "(" 1*address ")" / nil def nlist__address return if NIL? - lpar; list = [address]; list << address until rpar? + lpar; list = [address]; list << address until (quirky_SP?; rpar?) list end + # Used when servers erroneously send an extra SP. + # + # As of 2023-11-28, Outlook.com (still) sends SP + # between +address+ in env-* lists. + alias quirky_SP? SP? + alias env_from nlist__address alias env_sender nlist__address alias env_reply_to nlist__address diff --git a/test/net/imap/fixtures/response_parser/quirky_behaviors.yml b/test/net/imap/fixtures/response_parser/quirky_behaviors.yml index 45bc3d19d..ef3b18a33 100644 --- a/test/net/imap/fixtures/response_parser/quirky_behaviors.yml +++ b/test/net/imap/fixtures/response_parser/quirky_behaviors.yml @@ -31,3 +31,11 @@ unparsed_data: "froopy snood" raw_data: "* 86 NOOP froopy snood\r\n" + outlook.com puts an extra SP in ENVELOPE address lists: + comment: | + An annoying bug from outlook.com. They've had the bug for years, and + still have the bug as of 2023-11-28. + + The example comes from a real response, but all addesses have been + replaced by the `faker` gem. :) + :response: "* 24 FETCH (UID 60 INTERNALDATE \"24-May-2021 11:47:51 +0200\" RFC822.SIZE 49051 ENVELOPE (\"Mon, 24 May 20 21 09:47:50 +0000\" \"Zoooom Zoom\" ((\"Augustina Gleason\" NIL \"augustina\" \"oberbrunner.test\")) NIL NIL ((\"risa@harvey-lemke.test\" NIL \"risa\" \"harvey-lemke.test\") (\"shella@kilback-renner.test\" NIL \"shella\" \"kilback-renner.test\") (\"jana.kiehn@bradtke-considine.example\" NIL \"jana.kiehn\" \"bradtke-considine.example\") (\"frank@hartmann.test\" NIL \"frank\" \"hartmann.test\") (\"numbers.ryan@satterfield.test\" NIL \"numbers.ryan\" \"satterfield.test\") (\"keneth_feeney@will-walter.test\" NIL \"keneth_feeney\" \"will-walter.test\")) NIL NIL NIL \"\"))\r\n"