Skip to content

Commit 74b4004

Browse files
committed
🩹 Workaround buggy outlook.com address lists
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 addresses have been replaced by the `faker` gem. :)
1 parent 38d7530 commit 74b4004

File tree

2 files changed

+78
-1
lines changed

2 files changed

+78
-1
lines changed

lib/net/imap/response_parser.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ def envelope
978978
# env-bcc = "(" 1*address ")" / nil
979979
def nlist__address
980980
return if NIL?
981-
lpar; list = [address]; list << address until rpar?
981+
lpar; list = [address]; list << address until (quirky_SP?; rpar?)
982982
list
983983
end
984984

@@ -989,6 +989,12 @@ def nlist__address
989989
alias env_cc nlist__address
990990
alias env_bcc nlist__address
991991

992+
# Used when servers erroneously send an extra SP.
993+
#
994+
# As of 2023-11-28, Outlook.com (still) sends SP
995+
# between +address+ in <tt>env-*</tt> lists.
996+
alias quirky_SP? SP?
997+
992998
# date-time = DQUOTE date-day-fixed "-" date-month "-" date-year
993999
# SP time SP zone DQUOTE
9941000
alias date_time quoted

test/net/imap/fixtures/response_parser/quirky_behaviors.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,74 @@
3131
unparsed_data: "froopy snood"
3232
raw_data: "* 86 NOOP froopy snood\r\n"
3333

34+
outlook.com puts an extra SP in ENVELOPE address lists:
35+
comment: |
36+
An annoying bug from outlook.com. They've had the bug for years, and
37+
still have the bug as of 2023-11-28.
38+
39+
The example comes from a real response, but all addresses have been
40+
replaced by the `faker` gem. :)
41+
: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 ((\"[email protected]\" NIL \"risa\" \"harvey-lemke.test\") (\"[email protected]\" NIL \"shella\" \"kilback-renner.test\") (\"[email protected]\" NIL \"jana.kiehn\" \"bradtke-considine.example\") (\"[email protected]\" NIL \"frank\" \"hartmann.test\") (\"[email protected]\" NIL \"numbers.ryan\" \"satterfield.test\") (\"[email protected]\" NIL \"keneth_feeney\" \"will-walter.test\")) NIL NIL NIL \"<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@bbbbbbbbbbbbb.ccccccc.PROD.OUTLOOK.COM>\"))\r\n"
42+
:expected: !ruby/struct:Net::IMAP::UntaggedResponse
43+
name: FETCH
44+
data: !ruby/struct:Net::IMAP::FetchData
45+
seqno: 24
46+
attr:
47+
UID: 60
48+
INTERNALDATE: 24-May-2021 11:47:51 +0200
49+
RFC822.SIZE: 49051
50+
ENVELOPE: !ruby/struct:Net::IMAP::Envelope
51+
date: Mon, 24 May 20 21 09:47:50 +0000
52+
subject: Zoooom Zoom
53+
from:
54+
- !ruby/struct:Net::IMAP::Address
55+
name: Augustina Gleason
56+
route:
57+
mailbox: augustina
58+
host: oberbrunner.test
59+
sender:
60+
reply_to:
61+
to:
62+
- !ruby/struct:Net::IMAP::Address
63+
64+
route:
65+
mailbox: risa
66+
host: harvey-lemke.test
67+
- !ruby/struct:Net::IMAP::Address
68+
69+
route:
70+
mailbox: shella
71+
host: kilback-renner.test
72+
- !ruby/struct:Net::IMAP::Address
73+
74+
route:
75+
mailbox: jana.kiehn
76+
host: bradtke-considine.example
77+
- !ruby/struct:Net::IMAP::Address
78+
79+
route:
80+
mailbox: frank
81+
host: hartmann.test
82+
- !ruby/struct:Net::IMAP::Address
83+
84+
route:
85+
mailbox: numbers.ryan
86+
host: satterfield.test
87+
- !ruby/struct:Net::IMAP::Address
88+
89+
route:
90+
mailbox: keneth_feeney
91+
host: will-walter.test
92+
cc:
93+
bcc:
94+
in_reply_to:
95+
message_id: "<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@bbbbbbbbbbbbb.ccccccc.PROD.OUTLOOK.COM>"
96+
raw_data: "* 24 FETCH (UID 60 INTERNALDATE \"24-May-2021 11:47:51 +0200\" RFC822.SIZE
97+
49051 ENVELOPE (\"Mon, 24 May 20 21 09:47:50 +0000\" \"Zoooom Zoom\" ((\"Augustina
98+
Gleason\" NIL \"augustina\" \"oberbrunner.test\")) NIL NIL ((\"[email protected]\"
99+
NIL \"risa\" \"harvey-lemke.test\") (\"[email protected]\" NIL \"shella\"
100+
\"kilback-renner.test\") (\"[email protected]\" NIL \"jana.kiehn\"
101+
\"bradtke-considine.example\") (\"[email protected]\" NIL \"frank\" \"hartmann.test\")
102+
(\"[email protected]\" NIL \"numbers.ryan\" \"satterfield.test\")
103+
(\"[email protected]\" NIL \"keneth_feeney\" \"will-walter.test\"))
104+
NIL NIL NIL \"<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@bbbbbbbbbbbbb.ccccccc.PROD.OUTLOOK.COM>\"))\r\n"

0 commit comments

Comments
 (0)