--- /usr/lib/ruby/1.8/net/imap.rb 2006-11-15 20:30:03.000000000 -0700 +++ net/imap.rb 2006-11-19 15:31:41.000000000 -0700 @@ -1729,7 +1729,7 @@ # # multipart?:: Returns false. # - class BodyTypeBasic < Struct.new(:media_type, :subtype, + class BodyTypeBasic < Struct.new(:media_type, :subtype, :part_id, :param, :content_id, :description, :encoding, :size, :md5, :disposition, :language, @@ -1756,7 +1756,7 @@ # # And Net::IMAP::BodyTypeText has all fields of Net::IMAP::BodyTypeBasic. # - class BodyTypeText < Struct.new(:media_type, :subtype, + class BodyTypeText < Struct.new(:media_type, :subtype, :part_id, :param, :content_id, :description, :encoding, :size, :lines, @@ -1786,7 +1786,7 @@ # # And Net::IMAP::BodyTypeMessage has all methods of Net::IMAP::BodyTypeText. # - class BodyTypeMessage < Struct.new(:media_type, :subtype, + class BodyTypeMessage < Struct.new(:media_type, :subtype, :part_id, :param, :content_id, :description, :encoding, :size, :envelope, :body, :lines, @@ -1829,7 +1829,7 @@ # # multipart?:: Returns true. # - class BodyTypeMultipart < Struct.new(:media_type, :subtype, + class BodyTypeMultipart < Struct.new(:media_type, :subtype, :part_id, :parts, :param, :disposition, :language, :extension) @@ -2136,8 +2136,17 @@ return name, data end + def part_id + if @partids.empty? + 1 + else + @partids.join('.') + end + end + def body @lex_state = EXPR_DATA + @partids ||= [] token = lookahead if token.symbol == T_NIL shift_token @@ -2146,7 +2155,9 @@ match(T_LPAR) token = lookahead if token.symbol == T_LPAR + @partids.push 1 result = body_type_mpart + @partids.pop else result = body_type_1part end @@ -2172,12 +2183,12 @@ mtype, msubtype = media_type token = lookahead if token.symbol == T_RPAR - return BodyTypeBasic.new(mtype, msubtype) + return BodyTypeBasic.new(mtype, msubtype, part_id) end match(T_SPACE) param, content_id, desc, enc, size = body_fields md5, disposition, language, extension = body_ext_1part - return BodyTypeBasic.new(mtype, msubtype, + return BodyTypeBasic.new(mtype, msubtype, part_id, param, content_id, desc, enc, size, md5, disposition, language, extension) @@ -2190,7 +2201,7 @@ match(T_SPACE) lines = number md5, disposition, language, extension = body_ext_1part - return BodyTypeText.new(mtype, msubtype, + return BodyTypeText.new(mtype, msubtype, part_id, param, content_id, desc, enc, size, lines, @@ -2208,7 +2219,7 @@ match(T_SPACE) lines = number md5, disposition, language, extension = body_ext_1part - return BodyTypeMessage.new(mtype, msubtype, + return BodyTypeMessage.new(mtype, msubtype, part_id, param, content_id, desc, enc, size, env, b, lines, @@ -2224,11 +2235,12 @@ break end parts.push(body) + @partids.push @partids.pop + 1 end mtype = "MULTIPART" msubtype = case_insensitive_string param, disposition, language, extension = body_ext_mpart - return BodyTypeMultipart.new(mtype, msubtype, parts, + return BodyTypeMultipart.new(mtype, msubtype, part_id, parts, param, disposition, language, extension) end