Actions
Bug #10112
closedNET::IMAP fails to parse uid_search/search response with MODSEQ search criteria
Description
imap.examine('INBOX')
imap.uid_search(['MODSEQ', 12345])
NET::IMAP fails to parse uid_search/search response with MODSEQ search criteria (example above), here is the debug output I get from running it on GMAIL.
C: RUBY0002 EXAMINE INBOX
S: * FLAGS (\Answered \Flagged \Draft \Deleted \Seen $Phishing $Forwarded Seen $has_cal $NotJunk receipt-handled NotJunk $NotPhishing $Junk Junk)
S: * OK [PERMANENTFLAGS ()] Flags permitted.
S: * OK [UIDVALIDITY 2] UIDs valid.
S: * 3 EXISTS
S: * 0 RECENT
S: * OK [UIDNEXT 87222] Predicted next UID.
S: * OK [HIGHESTMODSEQ 7667593]
S: RUBY0002 OK [READ-ONLY] INBOX selected. (Success)
C: RUBY0003 UID SEARCH MODSEQ 7666341
S: * OK [HIGHESTMODSEQ 7667593]
S: * SEARCH 87216 87221 (MODSEQ 7667567)
@str: "* SEARCH 87216 87221 (MODSEQ 7667567)\r\n"
@pos: 22
@lex_state: EXPR_BEG
@token.symbol: LPAR
@token.value: "("
Updated by plehoux (Philippe-Antoine Lehoux) over 10 years ago
Here is my patch to parse the response successfully.
require 'net/imap'
##
# Fixing issue: NET::IMAP fails to parse uid_search/search response with MODSEQ search criteria
# https://bugs.ruby-lang.org/issues/10112
module Net # :nodoc:
class IMAP # :nodoc:
class ResponseParser # :nodoc:
def search_response
token = match(T_ATOM)
name = token.value.upcase
token = lookahead
if token.symbol == T_SPACE
shift_token
data = []
while true
token = lookahead
case token.symbol
when T_LPAR
shift_token
match(T_ATOM)
match(T_SPACE)
match(T_NUMBER)
match(T_RPAR)
when T_NUMBER
data.push(number)
when T_CRLF
break
else
shift_token
end
end
else
data = []
end
return UntaggedResponse.new(name, data, @str)
end
end
end
end
Updated by hsbt (Hiroshi SHIBATA) over 10 years ago
- Status changed from Open to Assigned
Updated by shugo (Shugo Maeda) about 10 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
Applied in changeset r48411.
- lib/net/imap.rb (search_response): parse MODSEQ in SEARCH
responses properly. [ruby-core:64203] [Bug #10112]
Actions
Like0
Like0Like0Like0