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"