Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions lib/net/imap/response_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1888,17 +1888,17 @@ def text?
# We leniently re-interpret this as
# resp-text = ["[" resp-text-code "]" [SP [text]] / [text]
def resp_text
state = current_state
if lbra?
code = resp_text_code; rbra
ResponseText.new(code, SP? && text? || "")
else
ResponseText.new(nil, text? || "")
begin
state = current_state
if lbra?
code = resp_text_code; rbra
return ResponseText.new(code, SP? && text? || "")
end
rescue ResponseParseError => error
raise if /\buid-set\b/i.match? error.message
restore_state state
end
rescue ResponseParseError => error
raise if /\buid-set\b/i.match? error.message
restore_state state
text
ResponseText.new(nil, text? || "")
end

# RFC3501 (See https://www.rfc-editor.org/errata/rfc3501):
Expand Down
15 changes: 7 additions & 8 deletions test/net/imap/fixtures/response_parser/quirky_behaviors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,20 @@

Microsoft Exchange is issuing an invalid resp-text-code, but net-imap
should fallback to `resp-text = text` when resp-text-code fails to parse.
:debug: false # current version of backtracking still prints parse_errors
:response: "RUBY0001 OK [Error=\"Microsoft.Exchange.Data.Storage.WrongServerException:
Cross Server access is not allowed for mailbox xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"
AuthResultFromPopImapEnd=0 Proxy=XXXXXXXXXXXXX.EURXXXX.PROD.OUTLOOK.COM:1993:SSL
MailboxBE=XXXXXXXXXXXXX.EURXXXX.PROD.OUTLOOK.COM
Service=Imap4] AUTHENTICATE completed.\r\n"
:expected: !ruby/struct:Net::IMAP::TaggedResponse
tag: RUBY0001
tag: RUBY0001
name: OK
data: '[Error="Microsoft.Exchange.Data.Storage.WrongServerException: Cross Server
access is not allowed for mailbox xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
AuthResultFromPopImapEnd=0
Proxy=XXXXXXXXXXXXX.EURXXXX.PROD.OUTLOOK.COM:1993:SSL
MailboxBE=XXXXXXXXXXXXX.EURXXXX.PROD.OUTLOOK.COM Service=Imap4]
AUTHENTICATE completed.'
data: !ruby/struct:Net::IMAP::ResponseText
code:
text: '[Error="Microsoft.Exchange.Data.Storage.WrongServerException: Cross Server
access is not allowed for mailbox xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" AuthResultFromPopImapEnd=0
Proxy=XXXXXXXXXXXXX.EURXXXX.PROD.OUTLOOK.COM:1993:SSL MailboxBE=XXXXXXXXXXXXX.EURXXXX.PROD.OUTLOOK.COM
Service=Imap4] AUTHENTICATE completed.'
raw_data: "RUBY0001 OK [Error=\"Microsoft.Exchange.Data.Storage.WrongServerException:
Cross Server access is not allowed for mailbox xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"
AuthResultFromPopImapEnd=0 Proxy=XXXXXXXXXXXXX.EURXXXX.PROD.OUTLOOK.COM:1993:SSL
Expand Down