Bug #17207 » imap.patch
w/lib/net/imap.rb | ||
---|---|---|
end
|
||
end
|
||
class BodyTypeExtension < Struct.new(:media_type, :subtype,
|
||
:params, :content_id,
|
||
:description, :encoding, :size)
|
||
def multipart?
|
||
return false
|
||
end
|
||
end
|
||
class ResponseParser # :nodoc:
|
||
def initialize
|
||
@str = nil
|
||
... | ... | |
def body_type_basic
|
||
mtype, msubtype = media_type
|
||
body_type_basic_fields(mtype, msubtype)
|
||
end
|
||
def body_type_basic_fields(mtype, msubtype)
|
||
token = lookahead
|
||
if token.symbol == T_RPAR
|
||
return BodyTypeBasic.new(mtype, msubtype)
|
||
... | ... | |
def body_type_msg
|
||
mtype, msubtype = media_type
|
||
unless msubtype.casecmp('RFC822') == 0
|
||
return body_type_basic_fields(mtype, msubtype)
|
||
end
|
||
match(T_SPACE)
|
||
param, content_id, desc, enc, size = body_fields
|
||
token = lookahead
|
||
if token.symbol == T_RPAR
|
||
# If this is not message/rfc822, we shouldn't apply the RFC822
|
||
# spec to it. We should handle anything other than
|
||
# message/rfc822 using multipart extension data [rfc3501] (i.e.
|
||
# the data itself won't be returned, we would have to retrieve it
|
||
# with BODYSTRUCTURE instead of with BODY
|
||
# Also, sometimes a message/rfc822 is included as a large
|
||
# Sometimes a message/rfc822 is included as a large
|
||
# attachment instead of having all of the other details
|
||
# (e.g. attaching a .eml file to an email)
|
||
if msubtype == "RFC822"
|
||
return BodyTypeMessage.new(mtype, msubtype, param, content_id,
|
||
desc, enc, size, nil, nil, nil, nil,
|
||
nil, nil, nil)
|
||
else
|
||
return BodyTypeExtension.new(mtype, msubtype,
|
||
param, content_id,
|
||
desc, enc, size)
|
||
end
|
||
return BodyTypeMessage.new(mtype, msubtype, param, content_id,
|
||
desc, enc, size, nil, nil, nil, nil,
|
||
nil, nil, nil)
|
||
end
|
||
match(T_SPACE)
|
w/test/net/imap/test_imap_response_parser.rb | ||
---|---|---|
assert_equal(nil, response.data.code)
|
||
assert_equal("", response.data.text)
|
||
end
|
||
def test_msg_with_message_disposition_notification
|
||
assert_parseable <<EOF
|
||
* 1 FETCH (UID 3 BODYSTRUCTURE (("TEXT" "PLAIN" ("CHARSET" "UTF-8") NIL NIL "QUOTED-PRINTABLE" 439 9 NIL NIL NIL NIL)("MESSAGE" "DISPOSITION-NOTIFICATION" ("NAME" "MDNPart2.txt") NIL NIL "7BIT" 304 NIL ("INLINE" ("FILENAME" "MDNPart2.txt" "SIZE" "304")) NIL NIL) "REPORT" ("REPORT-TYPE" "disposition-notification" "BOUNDARY" "=_6568a7f155bf754f458c22bcc1da9919") NIL NIL NIL))
|
||
EOF
|
||
end
|
||
end
|