mail 2.5.2 → 2.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.rdoc +124 -0
- data/CONTRIBUTING.md +21 -6
- data/Dependencies.txt +0 -1
- data/Gemfile +7 -22
- data/MIT-LICENSE +20 -0
- data/README.md +86 -31
- data/Rakefile +11 -22
- data/lib/mail/attachments_list.rb +4 -2
- data/lib/mail/body.rb +36 -11
- data/lib/mail/check_delivery_params.rb +13 -22
- data/lib/mail/configuration.rb +1 -0
- data/lib/mail/{patterns.rb → constants.rb} +29 -6
- data/lib/mail/core_extensions/smtp.rb +13 -13
- data/lib/mail/core_extensions/string/access.rb +1 -0
- data/lib/mail/core_extensions/string/multibyte.rb +1 -0
- data/lib/mail/core_extensions/string.rb +5 -17
- data/lib/mail/elements/address.rb +86 -145
- data/lib/mail/elements/address_list.rb +10 -42
- data/lib/mail/elements/content_disposition_element.rb +4 -7
- data/lib/mail/elements/content_location_element.rb +8 -11
- data/lib/mail/elements/content_transfer_encoding_element.rb +4 -10
- data/lib/mail/elements/content_type_element.rb +5 -8
- data/lib/mail/elements/date_time_element.rb +4 -7
- data/lib/mail/elements/envelope_from_element.rb +19 -13
- data/lib/mail/elements/message_ids_element.rb +8 -11
- data/lib/mail/elements/mime_version_element.rb +4 -7
- data/lib/mail/elements/phrase_list.rb +3 -7
- data/lib/mail/elements/received_element.rb +4 -7
- data/lib/mail/elements.rb +1 -0
- data/lib/mail/encodings/7bit.rb +1 -0
- data/lib/mail/encodings/8bit.rb +8 -2
- data/lib/mail/encodings/base64.rb +7 -1
- data/lib/mail/encodings/binary.rb +1 -0
- data/lib/mail/encodings/quoted_printable.rb +11 -4
- data/lib/mail/encodings/transfer_encoding.rb +27 -17
- data/lib/mail/encodings/unix_to_unix.rb +18 -0
- data/lib/mail/encodings.rb +54 -39
- data/lib/mail/envelope.rb +1 -5
- data/lib/mail/field.rb +81 -31
- data/lib/mail/field_list.rb +19 -18
- data/lib/mail/fields/bcc_field.rb +17 -5
- data/lib/mail/fields/cc_field.rb +3 -3
- data/lib/mail/fields/comments_field.rb +2 -1
- data/lib/mail/fields/common/address_container.rb +1 -0
- data/lib/mail/fields/common/common_address.rb +34 -28
- data/lib/mail/fields/common/common_date.rb +2 -8
- data/lib/mail/fields/common/common_field.rb +9 -5
- data/lib/mail/fields/common/common_message_id.rb +3 -2
- data/lib/mail/fields/common/parameter_hash.rb +4 -3
- data/lib/mail/fields/content_description_field.rb +1 -0
- data/lib/mail/fields/content_disposition_field.rb +13 -12
- data/lib/mail/fields/content_id_field.rb +4 -4
- data/lib/mail/fields/content_location_field.rb +2 -1
- data/lib/mail/fields/content_transfer_encoding_field.rb +4 -9
- data/lib/mail/fields/content_type_field.rb +4 -3
- data/lib/mail/fields/date_field.rb +16 -15
- data/lib/mail/fields/from_field.rb +3 -3
- data/lib/mail/fields/in_reply_to_field.rb +3 -1
- data/lib/mail/fields/keywords_field.rb +2 -2
- data/lib/mail/fields/message_id_field.rb +4 -4
- data/lib/mail/fields/mime_version_field.rb +3 -2
- data/lib/mail/fields/optional_field.rb +1 -0
- data/lib/mail/fields/received_field.rb +4 -3
- data/lib/mail/fields/references_field.rb +3 -1
- data/lib/mail/fields/reply_to_field.rb +3 -3
- data/lib/mail/fields/resent_bcc_field.rb +3 -3
- data/lib/mail/fields/resent_cc_field.rb +3 -3
- data/lib/mail/fields/resent_date_field.rb +2 -1
- data/lib/mail/fields/resent_from_field.rb +3 -3
- data/lib/mail/fields/resent_message_id_field.rb +1 -0
- data/lib/mail/fields/resent_sender_field.rb +4 -4
- data/lib/mail/fields/resent_to_field.rb +3 -3
- data/lib/mail/fields/return_path_field.rb +1 -1
- data/lib/mail/fields/sender_field.rb +9 -9
- data/lib/mail/fields/structured_field.rb +1 -0
- data/lib/mail/fields/subject_field.rb +1 -0
- data/lib/mail/fields/to_field.rb +3 -3
- data/lib/mail/fields/unstructured_field.rb +15 -8
- data/lib/mail/fields.rb +1 -0
- data/lib/mail/header.rb +21 -29
- data/lib/mail/indifferent_hash.rb +1 -0
- data/lib/mail/mail.rb +16 -1
- data/lib/mail/matchers/attachment_matchers.rb +29 -0
- data/lib/mail/matchers/has_sent_mail.rb +61 -4
- data/lib/mail/message.rb +175 -72
- data/lib/mail/multibyte/chars.rb +3 -2
- data/lib/mail/multibyte/exceptions.rb +1 -0
- data/lib/mail/multibyte/unicode.rb +22 -15
- data/lib/mail/multibyte/utils.rb +1 -0
- data/lib/mail/multibyte.rb +1 -0
- data/lib/mail/network/delivery_methods/exim.rb +3 -7
- data/lib/mail/network/delivery_methods/file_delivery.rb +2 -1
- data/lib/mail/network/delivery_methods/sendmail.rb +33 -10
- data/lib/mail/network/delivery_methods/smtp.rb +32 -34
- data/lib/mail/network/delivery_methods/smtp_connection.rb +7 -6
- data/lib/mail/network/delivery_methods/test_mailer.rb +3 -2
- data/lib/mail/network/retriever_methods/base.rb +1 -0
- data/lib/mail/network/retriever_methods/imap.rb +19 -13
- data/lib/mail/network/retriever_methods/pop3.rb +1 -0
- data/lib/mail/network/retriever_methods/test_retriever.rb +1 -0
- data/lib/mail/network.rb +1 -0
- data/lib/mail/parsers/address_lists_parser.rb +133 -0
- data/lib/mail/parsers/content_disposition_parser.rb +68 -0
- data/lib/mail/parsers/content_location_parser.rb +36 -0
- data/lib/mail/parsers/content_transfer_encoding_parser.rb +34 -0
- data/lib/mail/parsers/content_type_parser.rb +67 -0
- data/lib/mail/parsers/date_time_parser.rb +39 -0
- data/lib/mail/parsers/envelope_from_parser.rb +46 -0
- data/lib/mail/parsers/message_ids_parser.rb +40 -0
- data/lib/mail/parsers/mime_version_parser.rb +42 -0
- data/lib/mail/parsers/phrase_lists_parser.rb +36 -0
- data/lib/mail/parsers/ragel/common.rl +185 -0
- data/lib/mail/parsers/ragel/date_time.rl +30 -0
- data/lib/mail/parsers/ragel/parser_info.rb +61 -0
- data/lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb +14864 -0
- data/lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb +751 -0
- data/lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb +614 -0
- data/lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb +447 -0
- data/lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb +825 -0
- data/lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb +817 -0
- data/lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb +2149 -0
- data/lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb +1570 -0
- data/lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb +440 -0
- data/lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb +564 -0
- data/lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/machines/rb_actions.rl +51 -0
- data/lib/mail/parsers/ragel/ruby/machines/received_machine.rb +5144 -0
- data/lib/mail/parsers/ragel/ruby/machines/received_machine.rb.rl +37 -0
- data/lib/mail/parsers/ragel/ruby/parser.rb.rl.erb +37 -0
- data/lib/mail/parsers/ragel/ruby.rb +40 -0
- data/lib/mail/parsers/ragel.rb +18 -0
- data/lib/mail/parsers/received_parser.rb +49 -0
- data/lib/mail/parsers.rb +27 -0
- data/lib/mail/part.rb +11 -4
- data/lib/mail/parts_list.rb +30 -10
- data/lib/mail/utilities.rb +127 -63
- data/lib/mail/values/unicode_tables.dat +0 -0
- data/lib/mail/version.rb +8 -15
- data/lib/mail/version_specific/ruby_1_8.rb +18 -7
- data/lib/mail/version_specific/ruby_1_9.rb +136 -32
- data/lib/mail.rb +12 -6
- metadata +115 -77
- data/lib/VERSION +0 -4
- data/lib/load_parsers.rb +0 -41
- data/lib/mail/core_extensions/nil.rb +0 -19
- data/lib/mail/core_extensions/object.rb +0 -13
- data/lib/mail/core_extensions/shell_escape.rb +0 -56
- data/lib/mail/parsers/address_lists.rb +0 -64
- data/lib/mail/parsers/address_lists.treetop +0 -19
- data/lib/mail/parsers/content_disposition.rb +0 -535
- data/lib/mail/parsers/content_disposition.treetop +0 -46
- data/lib/mail/parsers/content_location.rb +0 -139
- data/lib/mail/parsers/content_location.treetop +0 -20
- data/lib/mail/parsers/content_transfer_encoding.rb +0 -162
- data/lib/mail/parsers/content_transfer_encoding.treetop +0 -20
- data/lib/mail/parsers/content_type.rb +0 -967
- data/lib/mail/parsers/content_type.treetop +0 -68
- data/lib/mail/parsers/date_time.rb +0 -114
- data/lib/mail/parsers/date_time.treetop +0 -11
- data/lib/mail/parsers/envelope_from.rb +0 -194
- data/lib/mail/parsers/envelope_from.treetop +0 -32
- data/lib/mail/parsers/message_ids.rb +0 -45
- data/lib/mail/parsers/message_ids.treetop +0 -15
- data/lib/mail/parsers/mime_version.rb +0 -144
- data/lib/mail/parsers/mime_version.treetop +0 -19
- data/lib/mail/parsers/phrase_lists.rb +0 -45
- data/lib/mail/parsers/phrase_lists.treetop +0 -15
- data/lib/mail/parsers/received.rb +0 -71
- data/lib/mail/parsers/received.treetop +0 -11
- data/lib/mail/parsers/rfc2045.rb +0 -464
- data/lib/mail/parsers/rfc2045.treetop +0 -36
- data/lib/mail/parsers/rfc2822.rb +0 -5397
- data/lib/mail/parsers/rfc2822.treetop +0 -410
- data/lib/mail/parsers/rfc2822_obsolete.rb +0 -3768
- data/lib/mail/parsers/rfc2822_obsolete.treetop +0 -241
- data/lib/tasks/corpus.rake +0 -125
- data/lib/tasks/treetop.rake +0 -10
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
module Mail
|
|
4
5
|
class Ruby18
|
|
@@ -54,19 +55,23 @@ module Mail
|
|
|
54
55
|
klass.const_get( string )
|
|
55
56
|
end
|
|
56
57
|
|
|
58
|
+
def Ruby18.transcode_charset(str, from_encoding, to_encoding = 'UTF-8')
|
|
59
|
+
Iconv.conv("#{normalize_iconv_charset_encoding(to_encoding)}//IGNORE", normalize_iconv_charset_encoding(from_encoding), str)
|
|
60
|
+
end
|
|
61
|
+
|
|
57
62
|
def Ruby18.b_value_encode(str, encoding)
|
|
58
63
|
# Ruby 1.8 requires an encoding to work
|
|
59
64
|
raise ArgumentError, "Must supply an encoding" if encoding.nil?
|
|
60
65
|
encoding = encoding.to_s.upcase.gsub('_', '-')
|
|
61
|
-
[Encodings::Base64.encode(str), encoding]
|
|
66
|
+
[Encodings::Base64.encode(str), normalize_iconv_charset_encoding(encoding)]
|
|
62
67
|
end
|
|
63
68
|
|
|
64
69
|
def Ruby18.b_value_decode(str)
|
|
65
|
-
match = str.match(/\=\?(.+)?\?[Bb]\?(
|
|
70
|
+
match = str.match(/\=\?(.+)?\?[Bb]\?(.*)\?\=/m)
|
|
66
71
|
if match
|
|
67
72
|
encoding = match[1]
|
|
68
73
|
str = Ruby18.decode_base64(match[2])
|
|
69
|
-
str =
|
|
74
|
+
str = transcode_charset(str, encoding)
|
|
70
75
|
end
|
|
71
76
|
str
|
|
72
77
|
end
|
|
@@ -79,14 +84,14 @@ module Mail
|
|
|
79
84
|
end
|
|
80
85
|
|
|
81
86
|
def Ruby18.q_value_decode(str)
|
|
82
|
-
match = str.match(/\=\?(.+)?\?[Qq]\?(
|
|
87
|
+
match = str.match(/\=\?(.+)?\?[Qq]\?(.*)\?\=/m)
|
|
83
88
|
if match
|
|
84
89
|
encoding = match[1]
|
|
85
90
|
string = match[2].gsub(/_/, '=20')
|
|
86
91
|
# Remove trailing = if it exists in a Q encoding
|
|
87
92
|
string = string.sub(/\=$/, '')
|
|
88
93
|
str = Encodings::QuotedPrintable.decode(string)
|
|
89
|
-
str =
|
|
94
|
+
str = transcode_charset(str, encoding)
|
|
90
95
|
end
|
|
91
96
|
str
|
|
92
97
|
end
|
|
@@ -103,10 +108,16 @@ module Mail
|
|
|
103
108
|
|
|
104
109
|
private
|
|
105
110
|
|
|
106
|
-
def Ruby18.
|
|
111
|
+
def Ruby18.normalize_iconv_charset_encoding(encoding)
|
|
107
112
|
case encoding.upcase
|
|
108
|
-
when 'UTF8'
|
|
113
|
+
when 'UTF8', 'UTF_8'
|
|
109
114
|
'UTF-8'
|
|
115
|
+
when 'UTF16', 'UTF-16'
|
|
116
|
+
'UTF-16BE'
|
|
117
|
+
when 'UTF32', 'UTF-32'
|
|
118
|
+
'UTF-32BE'
|
|
119
|
+
when 'KS_C_5601-1987'
|
|
120
|
+
'CP949'
|
|
110
121
|
else
|
|
111
122
|
encoding
|
|
112
123
|
end
|
|
@@ -1,7 +1,38 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
module Mail
|
|
4
5
|
class Ruby19
|
|
6
|
+
class StrictCharsetEncoder
|
|
7
|
+
def encode(string, charset)
|
|
8
|
+
string.force_encoding(Mail::Ruby19.pick_encoding(charset))
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class BestEffortCharsetEncoder
|
|
13
|
+
def encode(string, charset)
|
|
14
|
+
string.force_encoding(pick_encoding(charset))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def pick_encoding(charset)
|
|
20
|
+
charset = case charset
|
|
21
|
+
when /ansi_x3.110-1983/
|
|
22
|
+
'ISO-8859-1'
|
|
23
|
+
when /Windows-?1258/i # Windows-1258 is similar to 1252
|
|
24
|
+
"Windows-1252"
|
|
25
|
+
else
|
|
26
|
+
charset
|
|
27
|
+
end
|
|
28
|
+
Mail::Ruby19.pick_encoding(charset)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
class << self
|
|
33
|
+
attr_accessor :charset_encoder
|
|
34
|
+
end
|
|
35
|
+
self.charset_encoder = StrictCharsetEncoder.new
|
|
5
36
|
|
|
6
37
|
# Escapes any parenthesis in a string that are unescaped this uses
|
|
7
38
|
# a Ruby 1.9.1 regexp feature of negative look behind
|
|
@@ -43,20 +74,27 @@ module Mail
|
|
|
43
74
|
klass.const_get( string )
|
|
44
75
|
end
|
|
45
76
|
|
|
77
|
+
def Ruby19.transcode_charset(str, from_encoding, to_encoding = Encoding::UTF_8)
|
|
78
|
+
charset_encoder.encode(str.dup, from_encoding).encode(to_encoding, :undef => :replace, :invalid => :replace, :replace => '')
|
|
79
|
+
end
|
|
80
|
+
|
|
46
81
|
def Ruby19.b_value_encode(str, encoding = nil)
|
|
47
82
|
encoding = str.encoding.to_s
|
|
48
83
|
[Ruby19.encode_base64(str), encoding]
|
|
49
84
|
end
|
|
50
85
|
|
|
51
86
|
def Ruby19.b_value_decode(str)
|
|
52
|
-
match = str.match(/\=\?(.+)?\?[Bb]\?(
|
|
87
|
+
match = str.match(/\=\?(.+)?\?[Bb]\?(.*)\?\=/m)
|
|
53
88
|
if match
|
|
54
|
-
|
|
89
|
+
charset = match[1]
|
|
55
90
|
str = Ruby19.decode_base64(match[2])
|
|
56
|
-
str.
|
|
91
|
+
str = charset_encoder.encode(str, charset)
|
|
57
92
|
end
|
|
58
|
-
decoded = str.encode(
|
|
59
|
-
decoded.valid_encoding? ? decoded : decoded.encode(
|
|
93
|
+
decoded = str.encode(Encoding::UTF_8, :invalid => :replace, :replace => "")
|
|
94
|
+
decoded.valid_encoding? ? decoded : decoded.encode(Encoding::UTF_16LE, :invalid => :replace, :replace => "").encode(Encoding::UTF_8)
|
|
95
|
+
rescue Encoding::UndefinedConversionError, ArgumentError, Encoding::ConverterNotFoundError
|
|
96
|
+
warn "Encoding conversion failed #{$!}"
|
|
97
|
+
str.dup.force_encoding(Encoding::UTF_8)
|
|
60
98
|
end
|
|
61
99
|
|
|
62
100
|
def Ruby19.q_value_encode(str, encoding = nil)
|
|
@@ -65,25 +103,29 @@ module Mail
|
|
|
65
103
|
end
|
|
66
104
|
|
|
67
105
|
def Ruby19.q_value_decode(str)
|
|
68
|
-
match = str.match(/\=\?(.+)?\?[Qq]\?(
|
|
106
|
+
match = str.match(/\=\?(.+)?\?[Qq]\?(.*)\?\=/m)
|
|
69
107
|
if match
|
|
70
|
-
|
|
108
|
+
charset = match[1]
|
|
71
109
|
string = match[2].gsub(/_/, '=20')
|
|
72
110
|
# Remove trailing = if it exists in a Q encoding
|
|
73
111
|
string = string.sub(/\=$/, '')
|
|
74
112
|
str = Encodings::QuotedPrintable.decode(string)
|
|
75
|
-
str.
|
|
113
|
+
str = charset_encoder.encode(str, charset)
|
|
114
|
+
# We assume that binary strings hold utf-8 directly to work around
|
|
115
|
+
# jruby/jruby#829 which subtly changes String#encode semantics.
|
|
116
|
+
str.force_encoding(Encoding::UTF_8) if str.encoding == Encoding::ASCII_8BIT
|
|
76
117
|
end
|
|
77
|
-
decoded = str.encode(
|
|
78
|
-
decoded.valid_encoding? ? decoded : decoded.encode(
|
|
79
|
-
rescue Encoding::UndefinedConversionError
|
|
80
|
-
|
|
118
|
+
decoded = str.encode(Encoding::UTF_8, :invalid => :replace, :replace => "")
|
|
119
|
+
decoded.valid_encoding? ? decoded : decoded.encode(Encoding::UTF_16LE, :invalid => :replace, :replace => "").encode(Encoding::UTF_8)
|
|
120
|
+
rescue Encoding::UndefinedConversionError, ArgumentError, Encoding::ConverterNotFoundError
|
|
121
|
+
warn "Encoding conversion failed #{$!}"
|
|
122
|
+
str.dup.force_encoding(Encoding::UTF_8)
|
|
81
123
|
end
|
|
82
124
|
|
|
83
125
|
def Ruby19.param_decode(str, encoding)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
126
|
+
str = uri_parser.unescape(str)
|
|
127
|
+
str = charset_encoder.encode(str, encoding) if encoding
|
|
128
|
+
str
|
|
87
129
|
end
|
|
88
130
|
|
|
89
131
|
def Ruby19.param_encode(str)
|
|
@@ -96,23 +138,85 @@ module Mail
|
|
|
96
138
|
@uri_parser ||= URI::Parser.new
|
|
97
139
|
end
|
|
98
140
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
141
|
+
# Pick a Ruby encoding corresponding to the message charset. Most
|
|
142
|
+
# charsets have a Ruby encoding, but some need manual aliasing here.
|
|
143
|
+
#
|
|
144
|
+
# TODO: add this as a test somewhere:
|
|
145
|
+
# Encoding.list.map { |e| [e.to_s.upcase == pick_encoding(e.to_s.downcase.gsub("-", "")), e.to_s] }.select {|a,b| !b}
|
|
146
|
+
# Encoding.list.map { |e| [e.to_s == pick_encoding(e.to_s), e.to_s] }.select {|a,b| !b}
|
|
147
|
+
def Ruby19.pick_encoding(charset)
|
|
148
|
+
charset = charset.to_s
|
|
149
|
+
encoding = case charset.downcase
|
|
150
|
+
|
|
151
|
+
# ISO-8859-8-I etc. http://en.wikipedia.org/wiki/ISO-8859-8-I
|
|
152
|
+
when /^iso[-_]?8859-(\d+)(-i)?$/
|
|
153
|
+
"ISO-8859-#{$1}"
|
|
154
|
+
|
|
155
|
+
# ISO-8859-15, ISO-2022-JP and alike
|
|
156
|
+
when /^iso[-_]?(\d{4})-?(\w{1,2})$/
|
|
157
|
+
"ISO-#{$1}-#{$2}"
|
|
158
|
+
|
|
159
|
+
# "ISO-2022-JP-KDDI" and alike
|
|
160
|
+
when /^iso[-_]?(\d{4})-?(\w{1,2})-?(\w*)$/
|
|
161
|
+
"ISO-#{$1}-#{$2}-#{$3}"
|
|
162
|
+
|
|
163
|
+
# UTF-8, UTF-32BE and alike
|
|
164
|
+
when /^utf[\-_]?(\d{1,2})?(\w{1,2})$/
|
|
165
|
+
"UTF-#{$1}#{$2}".gsub(/\A(UTF-(?:16|32))\z/, '\\1BE')
|
|
166
|
+
|
|
167
|
+
# Windows-1252 and alike
|
|
168
|
+
when /^windows-?(.*)$/
|
|
169
|
+
"Windows-#{$1}"
|
|
170
|
+
|
|
171
|
+
when '8bit'
|
|
172
|
+
Encoding::ASCII_8BIT
|
|
173
|
+
|
|
174
|
+
# alternatives/misspellings of us-ascii seen in the wild
|
|
175
|
+
when /^iso[-_]?646(-us)?$/, 'us=ascii'
|
|
176
|
+
Encoding::ASCII
|
|
177
|
+
|
|
178
|
+
# Microsoft-specific alias for MACROMAN
|
|
179
|
+
when 'macintosh'
|
|
180
|
+
Encoding::MACROMAN
|
|
181
|
+
|
|
182
|
+
# Microsoft-specific alias for CP949 (Korean)
|
|
183
|
+
when 'ks_c_5601-1987'
|
|
184
|
+
Encoding::CP949
|
|
185
|
+
|
|
186
|
+
# Wrongly written Shift_JIS (Japanese)
|
|
187
|
+
when 'shift-jis'
|
|
188
|
+
Encoding::Shift_JIS
|
|
189
|
+
|
|
190
|
+
# GB2312 (Chinese charset) is a subset of GB18030 (its replacement)
|
|
191
|
+
when 'gb2312'
|
|
192
|
+
Encoding::GB18030
|
|
193
|
+
|
|
194
|
+
when 'cp-850'
|
|
195
|
+
Encoding::CP850
|
|
196
|
+
|
|
197
|
+
when 'latin2'
|
|
198
|
+
Encoding::ISO_8859_2
|
|
199
|
+
|
|
200
|
+
else
|
|
201
|
+
charset
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
convert_to_encoding(encoding)
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
class << self
|
|
208
|
+
private
|
|
209
|
+
|
|
210
|
+
def convert_to_encoding(encoding)
|
|
211
|
+
if encoding.is_a?(Encoding)
|
|
212
|
+
encoding
|
|
213
|
+
else
|
|
214
|
+
begin
|
|
215
|
+
Encoding.find(encoding)
|
|
216
|
+
rescue ArgumentError
|
|
217
|
+
Encoding::BINARY
|
|
218
|
+
end
|
|
219
|
+
end
|
|
116
220
|
end
|
|
117
221
|
end
|
|
118
222
|
end
|
data/lib/mail.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
module Mail # :doc:
|
|
3
4
|
|
|
4
5
|
require 'date'
|
|
@@ -6,7 +7,13 @@ module Mail # :doc:
|
|
|
6
7
|
|
|
7
8
|
require 'uri'
|
|
8
9
|
require 'net/smtp'
|
|
9
|
-
|
|
10
|
+
|
|
11
|
+
begin
|
|
12
|
+
# Use mime/types/columnar if available, for reduced memory usage
|
|
13
|
+
require 'mime/types/columnar'
|
|
14
|
+
rescue LoadError
|
|
15
|
+
require 'mime/types'
|
|
16
|
+
end
|
|
10
17
|
|
|
11
18
|
if RUBY_VERSION <= '1.8.6'
|
|
12
19
|
begin
|
|
@@ -26,10 +33,7 @@ module Mail # :doc:
|
|
|
26
33
|
|
|
27
34
|
require 'mail/version'
|
|
28
35
|
|
|
29
|
-
require 'mail/core_extensions/nil'
|
|
30
|
-
require 'mail/core_extensions/object'
|
|
31
36
|
require 'mail/core_extensions/string'
|
|
32
|
-
require 'mail/core_extensions/shell_escape'
|
|
33
37
|
require 'mail/core_extensions/smtp' if RUBY_VERSION < '1.9.3'
|
|
34
38
|
require 'mail/indifferent_hash'
|
|
35
39
|
|
|
@@ -42,7 +46,7 @@ module Mail # :doc:
|
|
|
42
46
|
require 'mail/multibyte'
|
|
43
47
|
end
|
|
44
48
|
|
|
45
|
-
require 'mail/
|
|
49
|
+
require 'mail/constants'
|
|
46
50
|
require 'mail/utilities'
|
|
47
51
|
require 'mail/configuration'
|
|
48
52
|
|
|
@@ -77,15 +81,17 @@ module Mail # :doc:
|
|
|
77
81
|
|
|
78
82
|
require 'mail/envelope'
|
|
79
83
|
|
|
80
|
-
|
|
84
|
+
register_autoload :Parsers, "mail/parsers"
|
|
81
85
|
|
|
82
86
|
# Autoload header field elements and transfer encodings.
|
|
83
87
|
require 'mail/elements'
|
|
84
88
|
require 'mail/encodings'
|
|
85
89
|
require 'mail/encodings/base64'
|
|
86
90
|
require 'mail/encodings/quoted_printable'
|
|
91
|
+
require 'mail/encodings/unix_to_unix'
|
|
87
92
|
|
|
88
93
|
require 'mail/matchers/has_sent_mail'
|
|
94
|
+
require 'mail/matchers/attachment_matchers.rb'
|
|
89
95
|
|
|
90
96
|
# Finally... require all the Mail.methods
|
|
91
97
|
require 'mail/mail'
|
metadata
CHANGED
|
@@ -1,64 +1,91 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mail
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 2.6.4
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Mikel Lindsaar
|
|
9
8
|
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 2016-03-23 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: mime-types
|
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
|
17
|
-
none: false
|
|
18
16
|
requirements:
|
|
19
|
-
- -
|
|
17
|
+
- - ">="
|
|
20
18
|
- !ruby/object:Gem::Version
|
|
21
19
|
version: '1.16'
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '4'
|
|
22
23
|
type: :runtime
|
|
23
24
|
prerelease: false
|
|
24
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
-
none: false
|
|
26
26
|
requirements:
|
|
27
|
-
- -
|
|
27
|
+
- - ">="
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
29
|
version: '1.16'
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '4'
|
|
30
33
|
- !ruby/object:Gem::Dependency
|
|
31
|
-
name:
|
|
34
|
+
name: bundler
|
|
32
35
|
requirement: !ruby/object:Gem::Requirement
|
|
33
|
-
none: false
|
|
34
36
|
requirements:
|
|
35
|
-
- -
|
|
37
|
+
- - ">="
|
|
36
38
|
- !ruby/object:Gem::Version
|
|
37
|
-
version: 1.
|
|
38
|
-
type: :
|
|
39
|
+
version: 1.0.3
|
|
40
|
+
type: :development
|
|
39
41
|
prerelease: false
|
|
40
42
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
-
none: false
|
|
42
43
|
requirements:
|
|
43
|
-
- -
|
|
44
|
+
- - ">="
|
|
44
45
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: 1.
|
|
46
|
+
version: 1.0.3
|
|
46
47
|
- !ruby/object:Gem::Dependency
|
|
47
|
-
name:
|
|
48
|
+
name: rake
|
|
48
49
|
requirement: !ruby/object:Gem::Requirement
|
|
49
|
-
none: false
|
|
50
50
|
requirements:
|
|
51
|
-
- -
|
|
51
|
+
- - ">"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: 0.
|
|
54
|
-
type: :
|
|
53
|
+
version: 0.8.7
|
|
54
|
+
type: :development
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: 0.8.7
|
|
61
|
+
- !ruby/object:Gem::Dependency
|
|
62
|
+
name: rspec
|
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '3.0'
|
|
68
|
+
type: :development
|
|
69
|
+
prerelease: false
|
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - "~>"
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '3.0'
|
|
75
|
+
- !ruby/object:Gem::Dependency
|
|
76
|
+
name: rdoc
|
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - ">="
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '0'
|
|
82
|
+
type: :development
|
|
55
83
|
prerelease: false
|
|
56
84
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
-
none: false
|
|
58
85
|
requirements:
|
|
59
|
-
- -
|
|
86
|
+
- - ">="
|
|
60
87
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 0
|
|
88
|
+
version: '0'
|
|
62
89
|
description: A really Ruby Mail handler.
|
|
63
90
|
email: raasdnil@gmail.com
|
|
64
91
|
executables: []
|
|
@@ -69,25 +96,25 @@ extra_rdoc_files:
|
|
|
69
96
|
- CHANGELOG.rdoc
|
|
70
97
|
- TODO.rdoc
|
|
71
98
|
files:
|
|
72
|
-
- README.md
|
|
73
|
-
- CONTRIBUTING.md
|
|
74
99
|
- CHANGELOG.rdoc
|
|
100
|
+
- CONTRIBUTING.md
|
|
75
101
|
- Dependencies.txt
|
|
76
102
|
- Gemfile
|
|
103
|
+
- MIT-LICENSE
|
|
104
|
+
- README.md
|
|
77
105
|
- Rakefile
|
|
78
106
|
- TODO.rdoc
|
|
79
|
-
- lib/
|
|
107
|
+
- lib/mail.rb
|
|
80
108
|
- lib/mail/attachments_list.rb
|
|
81
109
|
- lib/mail/body.rb
|
|
82
110
|
- lib/mail/check_delivery_params.rb
|
|
83
111
|
- lib/mail/configuration.rb
|
|
84
|
-
- lib/mail/
|
|
85
|
-
- lib/mail/core_extensions/object.rb
|
|
86
|
-
- lib/mail/core_extensions/shell_escape.rb
|
|
112
|
+
- lib/mail/constants.rb
|
|
87
113
|
- lib/mail/core_extensions/smtp.rb
|
|
114
|
+
- lib/mail/core_extensions/string.rb
|
|
88
115
|
- lib/mail/core_extensions/string/access.rb
|
|
89
116
|
- lib/mail/core_extensions/string/multibyte.rb
|
|
90
|
-
- lib/mail/
|
|
117
|
+
- lib/mail/elements.rb
|
|
91
118
|
- lib/mail/elements/address.rb
|
|
92
119
|
- lib/mail/elements/address_list.rb
|
|
93
120
|
- lib/mail/elements/content_disposition_element.rb
|
|
@@ -100,17 +127,18 @@ files:
|
|
|
100
127
|
- lib/mail/elements/mime_version_element.rb
|
|
101
128
|
- lib/mail/elements/phrase_list.rb
|
|
102
129
|
- lib/mail/elements/received_element.rb
|
|
103
|
-
- lib/mail/
|
|
130
|
+
- lib/mail/encodings.rb
|
|
104
131
|
- lib/mail/encodings/7bit.rb
|
|
105
132
|
- lib/mail/encodings/8bit.rb
|
|
106
133
|
- lib/mail/encodings/base64.rb
|
|
107
134
|
- lib/mail/encodings/binary.rb
|
|
108
135
|
- lib/mail/encodings/quoted_printable.rb
|
|
109
136
|
- lib/mail/encodings/transfer_encoding.rb
|
|
110
|
-
- lib/mail/encodings.rb
|
|
137
|
+
- lib/mail/encodings/unix_to_unix.rb
|
|
111
138
|
- lib/mail/envelope.rb
|
|
112
139
|
- lib/mail/field.rb
|
|
113
140
|
- lib/mail/field_list.rb
|
|
141
|
+
- lib/mail/fields.rb
|
|
114
142
|
- lib/mail/fields/bcc_field.rb
|
|
115
143
|
- lib/mail/fields/cc_field.rb
|
|
116
144
|
- lib/mail/fields/comments_field.rb
|
|
@@ -149,17 +177,18 @@ files:
|
|
|
149
177
|
- lib/mail/fields/subject_field.rb
|
|
150
178
|
- lib/mail/fields/to_field.rb
|
|
151
179
|
- lib/mail/fields/unstructured_field.rb
|
|
152
|
-
- lib/mail/fields.rb
|
|
153
180
|
- lib/mail/header.rb
|
|
154
181
|
- lib/mail/indifferent_hash.rb
|
|
155
182
|
- lib/mail/mail.rb
|
|
183
|
+
- lib/mail/matchers/attachment_matchers.rb
|
|
156
184
|
- lib/mail/matchers/has_sent_mail.rb
|
|
157
185
|
- lib/mail/message.rb
|
|
186
|
+
- lib/mail/multibyte.rb
|
|
158
187
|
- lib/mail/multibyte/chars.rb
|
|
159
188
|
- lib/mail/multibyte/exceptions.rb
|
|
160
189
|
- lib/mail/multibyte/unicode.rb
|
|
161
190
|
- lib/mail/multibyte/utils.rb
|
|
162
|
-
- lib/mail/
|
|
191
|
+
- lib/mail/network.rb
|
|
163
192
|
- lib/mail/network/delivery_methods/exim.rb
|
|
164
193
|
- lib/mail/network/delivery_methods/file_delivery.rb
|
|
165
194
|
- lib/mail/network/delivery_methods/sendmail.rb
|
|
@@ -170,69 +199,78 @@ files:
|
|
|
170
199
|
- lib/mail/network/retriever_methods/imap.rb
|
|
171
200
|
- lib/mail/network/retriever_methods/pop3.rb
|
|
172
201
|
- lib/mail/network/retriever_methods/test_retriever.rb
|
|
173
|
-
- lib/mail/
|
|
174
|
-
- lib/mail/parsers/
|
|
175
|
-
- lib/mail/parsers/
|
|
176
|
-
- lib/mail/parsers/
|
|
177
|
-
- lib/mail/parsers/
|
|
178
|
-
- lib/mail/parsers/
|
|
179
|
-
- lib/mail/parsers/
|
|
180
|
-
- lib/mail/parsers/
|
|
181
|
-
- lib/mail/parsers/
|
|
182
|
-
- lib/mail/parsers/
|
|
183
|
-
- lib/mail/parsers/
|
|
184
|
-
- lib/mail/parsers/
|
|
185
|
-
- lib/mail/parsers/
|
|
186
|
-
- lib/mail/parsers/
|
|
187
|
-
- lib/mail/parsers/
|
|
188
|
-
- lib/mail/parsers/
|
|
189
|
-
- lib/mail/parsers/
|
|
190
|
-
- lib/mail/parsers/
|
|
191
|
-
- lib/mail/parsers/
|
|
192
|
-
- lib/mail/parsers/
|
|
193
|
-
- lib/mail/parsers/
|
|
194
|
-
- lib/mail/parsers/
|
|
195
|
-
- lib/mail/parsers/
|
|
196
|
-
- lib/mail/parsers/
|
|
197
|
-
- lib/mail/parsers/
|
|
198
|
-
- lib/mail/parsers/
|
|
199
|
-
- lib/mail/parsers/
|
|
200
|
-
- lib/mail/parsers/
|
|
201
|
-
- lib/mail/parsers/
|
|
202
|
+
- lib/mail/parsers.rb
|
|
203
|
+
- lib/mail/parsers/address_lists_parser.rb
|
|
204
|
+
- lib/mail/parsers/content_disposition_parser.rb
|
|
205
|
+
- lib/mail/parsers/content_location_parser.rb
|
|
206
|
+
- lib/mail/parsers/content_transfer_encoding_parser.rb
|
|
207
|
+
- lib/mail/parsers/content_type_parser.rb
|
|
208
|
+
- lib/mail/parsers/date_time_parser.rb
|
|
209
|
+
- lib/mail/parsers/envelope_from_parser.rb
|
|
210
|
+
- lib/mail/parsers/message_ids_parser.rb
|
|
211
|
+
- lib/mail/parsers/mime_version_parser.rb
|
|
212
|
+
- lib/mail/parsers/phrase_lists_parser.rb
|
|
213
|
+
- lib/mail/parsers/ragel.rb
|
|
214
|
+
- lib/mail/parsers/ragel/common.rl
|
|
215
|
+
- lib/mail/parsers/ragel/date_time.rl
|
|
216
|
+
- lib/mail/parsers/ragel/parser_info.rb
|
|
217
|
+
- lib/mail/parsers/ragel/ruby.rb
|
|
218
|
+
- lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb
|
|
219
|
+
- lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb.rl
|
|
220
|
+
- lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb
|
|
221
|
+
- lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb.rl
|
|
222
|
+
- lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb
|
|
223
|
+
- lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb.rl
|
|
224
|
+
- lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb
|
|
225
|
+
- lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb.rl
|
|
226
|
+
- lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb
|
|
227
|
+
- lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb.rl
|
|
228
|
+
- lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb
|
|
229
|
+
- lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb.rl
|
|
230
|
+
- lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb
|
|
231
|
+
- lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb.rl
|
|
232
|
+
- lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb
|
|
233
|
+
- lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb.rl
|
|
234
|
+
- lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb
|
|
235
|
+
- lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb.rl
|
|
236
|
+
- lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb
|
|
237
|
+
- lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb.rl
|
|
238
|
+
- lib/mail/parsers/ragel/ruby/machines/rb_actions.rl
|
|
239
|
+
- lib/mail/parsers/ragel/ruby/machines/received_machine.rb
|
|
240
|
+
- lib/mail/parsers/ragel/ruby/machines/received_machine.rb.rl
|
|
241
|
+
- lib/mail/parsers/ragel/ruby/parser.rb.rl.erb
|
|
242
|
+
- lib/mail/parsers/received_parser.rb
|
|
202
243
|
- lib/mail/part.rb
|
|
203
244
|
- lib/mail/parts_list.rb
|
|
204
|
-
- lib/mail/patterns.rb
|
|
205
245
|
- lib/mail/utilities.rb
|
|
206
246
|
- lib/mail/values/unicode_tables.dat
|
|
207
247
|
- lib/mail/version.rb
|
|
208
248
|
- lib/mail/version_specific/ruby_1_8.rb
|
|
209
249
|
- lib/mail/version_specific/ruby_1_9.rb
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
-
|
|
213
|
-
|
|
214
|
-
homepage: http://github.com/mikel/mail
|
|
215
|
-
licenses: []
|
|
250
|
+
homepage: https://github.com/mikel/mail
|
|
251
|
+
licenses:
|
|
252
|
+
- MIT
|
|
253
|
+
metadata: {}
|
|
216
254
|
post_install_message:
|
|
217
|
-
rdoc_options:
|
|
255
|
+
rdoc_options:
|
|
256
|
+
- "--exclude"
|
|
257
|
+
- lib/mail/values/unicode_tables.dat
|
|
218
258
|
require_paths:
|
|
219
259
|
- lib
|
|
220
260
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
221
|
-
none: false
|
|
222
261
|
requirements:
|
|
223
|
-
- -
|
|
262
|
+
- - ">="
|
|
224
263
|
- !ruby/object:Gem::Version
|
|
225
264
|
version: '0'
|
|
226
265
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
|
-
none: false
|
|
228
266
|
requirements:
|
|
229
|
-
- -
|
|
267
|
+
- - ">="
|
|
230
268
|
- !ruby/object:Gem::Version
|
|
231
269
|
version: '0'
|
|
232
270
|
requirements: []
|
|
233
271
|
rubyforge_project:
|
|
234
|
-
rubygems_version:
|
|
272
|
+
rubygems_version: 2.5.1
|
|
235
273
|
signing_key:
|
|
236
|
-
specification_version:
|
|
274
|
+
specification_version: 4
|
|
237
275
|
summary: Mail provides a nice Ruby DSL for making, sending and reading emails.
|
|
238
276
|
test_files: []
|
data/lib/VERSION
DELETED