Skip to content

Commit

Permalink
🩹 Workaround buggy outlook.com address lists
Browse files Browse the repository at this point in the history
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. :)
  • Loading branch information
nevans committed Nov 29, 2023
1 parent 38d7530 commit 2c5c968
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/net/imap/response_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 <tt>env-*</tt> lists.
alias quirky_SP? SP?

alias env_from nlist__address
alias env_sender nlist__address
alias env_reply_to nlist__address
Expand Down
8 changes: 8 additions & 0 deletions test/net/imap/fixtures/response_parser/quirky_behaviors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ((\"[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"

0 comments on commit 2c5c968

Please sign in to comment.