Feature #10119 » modseq-changedsince-changes-UPDATED.patch
lib/net/imap.rb | ||
---|---|---|
# #=> "12-Oct-2000 22:40:59 +0900"
|
||
# p data.attr["UID"]
|
||
# #=> 98
|
||
def fetch(set, attr)
|
||
return fetch_internal("FETCH", set, attr)
|
||
def fetch(set, attr, mod = nil)
|
||
return fetch_internal("FETCH", set, attr, mod)
|
||
end
|
||
# Similar to #fetch(), but +set+ contains unique identifiers.
|
||
def uid_fetch(set, attr)
|
||
return fetch_internal("UID FETCH", set, attr)
|
||
def uid_fetch(set, attr, mod = nil)
|
||
return fetch_internal("UID FETCH", set, attr, mod)
|
||
end
|
||
# Sends a STORE command to alter data associated with messages
|
||
... | ... | |
when Integer
|
||
NumValidator.ensure_number(data)
|
||
when Array
|
||
data.each do |i|
|
||
validate_data(i)
|
||
if data[0] == 'CHANGEDSINCE'
|
||
NumValidator.ensure_mod_sequence_value(data[1])
|
||
else
|
||
data.each do |i|
|
||
validate_data(i)
|
||
end
|
||
end
|
||
when Time
|
||
when Symbol
|
||
... | ... | |
end
|
||
end
|
||
def fetch_internal(cmd, set, attr)
|
||
def fetch_internal(cmd, set, attr, mod = nil)
|
||
case attr
|
||
when String then
|
||
attr = RawData.new(attr)
|
||
... | ... | |
synchronize do
|
||
@responses.delete("FETCH")
|
||
send_command(cmd, MessageSet.new(set), attr)
|
||
if mod
|
||
send_command(cmd, MessageSet.new(set), attr, mod)
|
||
else
|
||
send_command(cmd, MessageSet.new(set), attr)
|
||
end
|
||
return @responses.delete("FETCH")
|
||
end
|
||
end
|
||
... | ... | |
num != 0 && valid_number?(num)
|
||
end
|
||
# Check is passed argument valid 'mod_sequence_value' in RFC 4551 terminology
|
||
def valid_mod_sequence_value?(num)
|
||
# mod-sequence-value = 1*DIGIT
|
||
# ; Positive unsigned 64-bit integer
|
||
# ; (mod-sequence)
|
||
# ; (1 <= n < 18,446,744,073,709,551,615)
|
||
num >= 1 && num < 18446744073709551615
|
||
end
|
||
# Ensure argument is 'number' or raise DataFormatError
|
||
def ensure_number(num)
|
||
return if valid_number?(num)
|
||
... | ... | |
msg = "nz_number must be non-zero unsigned 32-bit integer: #{num}"
|
||
raise DataFormatError, msg
|
||
end
|
||
# Ensure argument is 'mod_sequence_value' or raise DataFormatError
|
||
def ensure_mod_sequence_value(num)
|
||
return if valid_mod_sequence_value?(num)
|
||
msg = "mod_sequence_value must be unsigned 64-bit integer: #{num}"
|
||
raise DataFormatError, msg
|
||
end
|
||
end
|
||
end
|
||
... | ... | |
name, val = body_data
|
||
when /\A(?:UID)\z/ni
|
||
name, val = uid_data
|
||
when /\A(?:MODSEQ)\z/ni
|
||
name, val = modseq_data
|
||
else
|
||
parse_error("unknown attribute `%s' for {%d}", token.value, n)
|
||
end
|
||
... | ... | |
return name, number
|
||
end
|
||
def modseq_data
|
||
token = match(T_ATOM)
|
||
name = token.value.upcase
|
||
match(T_SPACE)
|
||
match(T_LPAR)
|
||
modseq = number
|
||
match(T_RPAR)
|
||
return name, modseq
|
||
end
|
||
def text_response
|
||
token = match(T_ATOM)
|
||
name = token.value.upcase
|
test/net/imap/test_imap_response_parser.rb | ||
---|---|---|
assert_equal("test.xml", body.parts[1].disposition.param["FILENAME"])
|
||
assert_equal(nil, body.parts[1].language)
|
||
end
|
||
# [Bug #10119]
|
||
def test_msg_att_modseq_data
|
||
parser = Net::IMAP::ResponseParser.new
|
||
response = parser.parse("* 1 FETCH (FLAGS (\Seen) MODSEQ (12345) UID 5)\r\n")
|
||
assert_equal(12345, response.data.attr["MODSEQ"])
|
||
end
|
||
end
|
- « Previous
- 1
- 2
- Next »