mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/net/imap.rb (body_type_attachment): parse body type
"ATTACHMENT". [ruby-core:44849] [Bug #6397] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0fce0545b6
commit
9be3aa1767
3 changed files with 44 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Mon May 7 13:03:55 2012 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/net/imap.rb (body_type_attachment): parse body type
|
||||||
|
"ATTACHMENT". [ruby-core:44849] [Bug #6397]
|
||||||
|
|
||||||
Mon May 7 10:49:36 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
Mon May 7 10:49:36 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* ext/bigdecimal/bigdecimal.c (Init_bigdecimal): define IDs before
|
* ext/bigdecimal/bigdecimal.c (Init_bigdecimal): define IDs before
|
||||||
|
|
|
@ -1977,6 +1977,26 @@ module Net
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Net::IMAP::BodyTypeAttachment represents attachment body structures
|
||||||
|
# of messages.
|
||||||
|
#
|
||||||
|
# ==== Fields:
|
||||||
|
#
|
||||||
|
# media_type:: Returns the content media type name.
|
||||||
|
#
|
||||||
|
# subtype:: Returns +nil+.
|
||||||
|
#
|
||||||
|
# param:: Returns a hash that represents parameters.
|
||||||
|
#
|
||||||
|
# multipart?:: Returns false.
|
||||||
|
#
|
||||||
|
class BodyTypeAttachment < Struct.new(:media_type, :subtype,
|
||||||
|
:param)
|
||||||
|
def multipart?
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Net::IMAP::BodyTypeMultipart represents multipart body structures
|
# Net::IMAP::BodyTypeMultipart represents multipart body structures
|
||||||
# of messages.
|
# of messages.
|
||||||
#
|
#
|
||||||
|
@ -2347,6 +2367,8 @@ module Net
|
||||||
return body_type_text
|
return body_type_text
|
||||||
when /\A(?:MESSAGE)\z/ni
|
when /\A(?:MESSAGE)\z/ni
|
||||||
return body_type_msg
|
return body_type_msg
|
||||||
|
when /\A(?:ATTACHMENT)\z/ni
|
||||||
|
return body_type_attachment
|
||||||
else
|
else
|
||||||
return body_type_basic
|
return body_type_basic
|
||||||
end
|
end
|
||||||
|
@ -2399,6 +2421,13 @@ module Net
|
||||||
md5, disposition, language, extension)
|
md5, disposition, language, extension)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def body_type_attachment
|
||||||
|
mtype = case_insensitive_string
|
||||||
|
match(T_SPACE)
|
||||||
|
param = body_fld_param
|
||||||
|
return BodyTypeAttachment.new(mtype, nil, param)
|
||||||
|
end
|
||||||
|
|
||||||
def body_type_mpart
|
def body_type_mpart
|
||||||
parts = []
|
parts = []
|
||||||
while true
|
while true
|
||||||
|
|
|
@ -142,4 +142,14 @@ foo
|
||||||
EOF
|
EOF
|
||||||
assert_equal("foo\r\n", response.data.attr["RFC822"])
|
assert_equal("foo\r\n", response.data.attr["RFC822"])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# [Bug #6397] [ruby-core:44849]
|
||||||
|
def test_body_type_attachment
|
||||||
|
parser = Net::IMAP::ResponseParser.new
|
||||||
|
response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
|
||||||
|
* 980 FETCH (UID 2862 BODYSTRUCTURE ((("TEXT" "PLAIN" ("CHARSET" "iso-8859-1") NIL NIL "7BIT" 416 21 NIL NIL NIL)("TEXT" "HTML" ("CHARSET" "iso-8859-1") NIL NIL "7BIT" 1493 32 NIL NIL NIL) "ALTERNATIVE" ("BOUNDARY" "Boundary_(ID_IaecgfnXwG5bn3x8lIeGIQ)") NIL NIL)("MESSAGE" "RFC822" ("NAME" "Fw_ ____ _____ ____.eml") NIL NIL "7BIT" 1980088 NIL ("ATTACHMENT" ("FILENAME" "Fw_ ____ _____ ____.eml")) NIL) "MIXED" ("BOUNDARY" "Boundary_(ID_eDdLc/j0mBIzIlR191pHjA)") NIL NIL))
|
||||||
|
EOF
|
||||||
|
assert_equal("Fw_ ____ _____ ____.eml",
|
||||||
|
response.data.attr["BODYSTRUCTURE"].parts[1].body.param["FILENAME"])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue