mail 2.7.0.rc1 → 2.7.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +71 -98
  3. data/lib/mail.rb +1 -6
  4. data/lib/mail/attachments_list.rb +5 -2
  5. data/lib/mail/body.rb +39 -33
  6. data/lib/mail/check_delivery_params.rb +8 -6
  7. data/lib/mail/configuration.rb +2 -0
  8. data/lib/mail/elements/address.rb +19 -18
  9. data/lib/mail/encodings.rb +89 -31
  10. data/lib/mail/encodings/7bit.rb +5 -15
  11. data/lib/mail/encodings/8bit.rb +2 -21
  12. data/lib/mail/encodings/base64.rb +11 -12
  13. data/lib/mail/encodings/binary.rb +3 -22
  14. data/lib/mail/encodings/identity.rb +24 -0
  15. data/lib/mail/encodings/quoted_printable.rb +6 -6
  16. data/lib/mail/encodings/transfer_encoding.rb +38 -29
  17. data/lib/mail/encodings/unix_to_unix.rb +2 -1
  18. data/lib/mail/envelope.rb +1 -1
  19. data/lib/mail/field.rb +93 -61
  20. data/lib/mail/fields/bcc_field.rb +2 -2
  21. data/lib/mail/fields/cc_field.rb +1 -1
  22. data/lib/mail/fields/comments_field.rb +1 -1
  23. data/lib/mail/fields/common/common_address.rb +32 -7
  24. data/lib/mail/fields/common/common_field.rb +1 -10
  25. data/lib/mail/fields/content_description_field.rb +1 -1
  26. data/lib/mail/fields/content_disposition_field.rb +3 -3
  27. data/lib/mail/fields/content_id_field.rb +2 -2
  28. data/lib/mail/fields/content_location_field.rb +1 -1
  29. data/lib/mail/fields/content_transfer_encoding_field.rb +1 -1
  30. data/lib/mail/fields/content_type_field.rb +1 -1
  31. data/lib/mail/fields/date_field.rb +2 -3
  32. data/lib/mail/fields/from_field.rb +1 -1
  33. data/lib/mail/fields/in_reply_to_field.rb +1 -1
  34. data/lib/mail/fields/keywords_field.rb +1 -1
  35. data/lib/mail/fields/message_id_field.rb +1 -1
  36. data/lib/mail/fields/mime_version_field.rb +1 -1
  37. data/lib/mail/fields/optional_field.rb +4 -1
  38. data/lib/mail/fields/received_field.rb +1 -1
  39. data/lib/mail/fields/references_field.rb +1 -1
  40. data/lib/mail/fields/reply_to_field.rb +1 -1
  41. data/lib/mail/fields/resent_bcc_field.rb +1 -1
  42. data/lib/mail/fields/resent_cc_field.rb +1 -1
  43. data/lib/mail/fields/resent_date_field.rb +0 -1
  44. data/lib/mail/fields/resent_from_field.rb +1 -1
  45. data/lib/mail/fields/resent_message_id_field.rb +1 -1
  46. data/lib/mail/fields/resent_sender_field.rb +1 -1
  47. data/lib/mail/fields/resent_to_field.rb +1 -1
  48. data/lib/mail/fields/return_path_field.rb +1 -1
  49. data/lib/mail/fields/sender_field.rb +1 -1
  50. data/lib/mail/fields/subject_field.rb +1 -1
  51. data/lib/mail/fields/to_field.rb +1 -1
  52. data/lib/mail/fields/unstructured_field.rb +19 -2
  53. data/lib/mail/header.rb +9 -8
  54. data/lib/mail/mail.rb +2 -10
  55. data/lib/mail/matchers/has_sent_mail.rb +21 -1
  56. data/lib/mail/message.rb +64 -51
  57. data/lib/mail/multibyte.rb +14 -16
  58. data/lib/mail/multibyte/chars.rb +2 -1
  59. data/lib/mail/network.rb +1 -0
  60. data/lib/mail/network/delivery_methods/exim.rb +6 -10
  61. data/lib/mail/network/delivery_methods/logger_delivery.rb +37 -0
  62. data/lib/mail/network/delivery_methods/sendmail.rb +8 -4
  63. data/lib/mail/network/delivery_methods/smtp.rb +56 -55
  64. data/lib/mail/network/delivery_methods/smtp_connection.rb +9 -1
  65. data/lib/mail/network/retriever_methods/imap.rb +18 -5
  66. data/lib/mail/network/retriever_methods/pop3.rb +3 -1
  67. data/lib/mail/parser_tools.rb +15 -0
  68. data/lib/mail/parsers/address_lists_parser.rb +30462 -12597
  69. data/lib/mail/parsers/address_lists_parser.rl +18 -12
  70. data/lib/mail/parsers/content_disposition_parser.rb +405 -215
  71. data/lib/mail/parsers/content_disposition_parser.rl +11 -5
  72. data/lib/mail/parsers/content_location_parser.rb +443 -208
  73. data/lib/mail/parsers/content_location_parser.rl +9 -3
  74. data/lib/mail/parsers/content_transfer_encoding_parser.rb +180 -80
  75. data/lib/mail/parsers/content_transfer_encoding_parser.rl +8 -2
  76. data/lib/mail/parsers/content_type_parser.rb +436 -245
  77. data/lib/mail/parsers/content_type_parser.rl +12 -6
  78. data/lib/mail/parsers/date_time_parser.rb +172 -72
  79. data/lib/mail/parsers/date_time_parser.rl +10 -4
  80. data/lib/mail/parsers/envelope_from_parser.rb +2833 -1320
  81. data/lib/mail/parsers/envelope_from_parser.rl +9 -3
  82. data/lib/mail/parsers/message_ids_parser.rb +2325 -976
  83. data/lib/mail/parsers/message_ids_parser.rl +9 -3
  84. data/lib/mail/parsers/mime_version_parser.rb +164 -64
  85. data/lib/mail/parsers/mime_version_parser.rl +9 -3
  86. data/lib/mail/parsers/phrase_lists_parser.rb +582 -237
  87. data/lib/mail/parsers/phrase_lists_parser.rl +9 -3
  88. data/lib/mail/parsers/received_parser.rb +7036 -3004
  89. data/lib/mail/parsers/received_parser.rl +11 -5
  90. data/lib/mail/parsers/rfc2045_content_transfer_encoding.rl +1 -0
  91. data/lib/mail/parsers/rfc2045_content_type.rl +1 -0
  92. data/lib/mail/parsers/rfc2045_mime.rl +1 -0
  93. data/lib/mail/parsers/rfc2183_content_disposition.rl +1 -0
  94. data/lib/mail/parsers/rfc3629_utf8.rl +19 -0
  95. data/lib/mail/parsers/rfc5234_abnf_core_rules.rl +7 -1
  96. data/lib/mail/parsers/rfc5322.rl +3 -1
  97. data/lib/mail/parsers/rfc5322_address.rl +3 -1
  98. data/lib/mail/parsers/rfc5322_date_time.rl +1 -0
  99. data/lib/mail/parsers/rfc5322_lexical_tokens.rl +9 -5
  100. data/lib/mail/part.rb +1 -1
  101. data/lib/mail/utilities.rb +44 -15
  102. data/lib/mail/version.rb +1 -1
  103. data/lib/mail/version_specific/ruby_1_8.rb +12 -1
  104. data/lib/mail/version_specific/ruby_1_9.rb +13 -1
  105. metadata +7 -13
  106. data/CHANGELOG.rdoc +0 -822
  107. data/CONTRIBUTING.md +0 -60
  108. data/Dependencies.txt +0 -1
  109. data/Gemfile +0 -11
  110. data/Rakefile +0 -23
  111. data/TODO.rdoc +0 -9
  112. data/lib/mail/multibyte/exceptions.rb +0 -9
@@ -1,18 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
  require 'mail/utilities'
3
+ require 'mail/parser_tools'
3
4
 
4
5
  %%{
5
6
  # RFC 2557 Content-Location
6
7
  # https://tools.ietf.org/html/rfc2557#section-4.1
7
8
  machine content_location;
9
+ alphtype int;
8
10
 
9
11
  # Quoted String
10
12
  action qstr_s { qstr_s = p }
11
- action qstr_e { content_location.location = data[qstr_s..(p-1)] }
13
+ action qstr_e { content_location.location = chars(data, qstr_s, p-1) }
12
14
 
13
15
  # Token String
14
16
  action token_string_s { token_string_s = p }
15
- action token_string_e { content_location.location = data[token_string_s..(p-1)] }
17
+ action token_string_e { content_location.location = chars(data, token_string_s, p-1) }
16
18
 
17
19
  # No-op actions
18
20
  action comment_e { }
@@ -36,11 +38,15 @@ require 'mail/utilities'
36
38
 
37
39
  module Mail::Parsers
38
40
  module ContentLocationParser
41
+ extend Mail::ParserTools
42
+
39
43
  ContentLocationStruct = Struct.new(:location, :error)
40
44
 
41
45
  %%write data noprefix;
42
46
 
43
47
  def self.parse(data)
48
+ data = data.dup.force_encoding(Encoding::ASCII_8BIT) if data.respond_to?(:force_encoding)
49
+
44
50
  content_location = ContentLocationStruct.new(nil)
45
51
  return content_location if Mail::Utilities.blank?(data)
46
52
 
@@ -56,7 +62,7 @@ module Mail::Parsers
56
62
  %%write exec;
57
63
 
58
64
  if p != eof || cs < %%{ write first_final; }%%
59
- raise Mail::Field::ParseError.new(Mail::ContentLocationElement, data, "Only able to parse up to #{data[0..p]}")
65
+ raise Mail::Field::IncompleteParseError.new(Mail::ContentLocationElement, data, p)
60
66
  end
61
67
 
62
68
  content_location
@@ -1,12 +1,15 @@
1
1
 
2
2
  # frozen_string_literal: true
3
3
  require 'mail/utilities'
4
+ require 'mail/parser_tools'
4
5
 
5
6
 
6
7
 
7
8
 
8
9
  module Mail::Parsers
9
10
  module ContentTransferEncodingParser
11
+ extend Mail::ParserTools
12
+
10
13
  ContentTransferEncodingStruct = Struct.new(:encoding, :error)
11
14
 
12
15
 
@@ -18,11 +21,14 @@ self._trans_keys = [
18
21
  0, 0, 9, 126, 10, 10,
19
22
  9, 32, 10, 10, 9,
20
23
  32, 10, 10, 9, 32,
21
- 9, 126, 1, 127, 1, 127,
24
+ 9, 126, 1, 244, 1, 244,
22
25
  10, 10, 9, 32, 0,
23
- 127, 9, 126, 9, 59,
24
- 9, 59, 9, 40, 9, 40,
25
- 0, 0, 0
26
+ 244, 128, 191, 160, 191,
27
+ 128, 191, 128, 159, 144, 191,
28
+ 128, 191, 128, 143, 9,
29
+ 126, 9, 59, 9, 59,
30
+ 9, 40, 9, 40, 0, 0,
31
+ 0
26
32
  ]
27
33
 
28
34
  class << self
@@ -31,8 +37,9 @@ class << self
31
37
  end
32
38
  self._key_spans = [
33
39
  0, 118, 1, 24, 1, 24, 1, 24,
34
- 118, 127, 127, 1, 24, 128, 118, 51,
35
- 51, 32, 32, 0
40
+ 118, 244, 244, 1, 24, 245, 64, 32,
41
+ 64, 32, 48, 64, 16, 118, 51, 51,
42
+ 32, 32, 0
36
43
  ]
37
44
 
38
45
  class << self
@@ -41,8 +48,9 @@ class << self
41
48
  end
42
49
  self._index_offsets = [
43
50
  0, 0, 119, 121, 146, 148, 173, 175,
44
- 200, 319, 447, 575, 577, 602, 731, 850,
45
- 902, 954, 987, 1020
51
+ 200, 319, 564, 809, 811, 836, 1082, 1147,
52
+ 1180, 1245, 1278, 1327, 1392, 1409, 1528, 1580,
53
+ 1632, 1665, 1698
46
54
  ]
47
55
 
48
56
  class << self
@@ -105,79 +113,164 @@ self._indicies = [
105
113
  14, 14, 14, 14, 14, 14, 14, 14,
106
114
  14, 14, 14, 14, 14, 14, 14, 14,
107
115
  14, 14, 14, 14, 14, 14, 14, 14,
108
- 14, 14, 14, 14, 14, 14, 1, 19,
109
- 19, 19, 19, 19, 19, 19, 19, 19,
110
- 1, 19, 19, 20, 19, 19, 19, 19,
111
- 19, 19, 19, 19, 19, 19, 19, 19,
112
- 19, 19, 19, 19, 19, 19, 19, 19,
113
- 19, 19, 19, 19, 19, 19, 21, 22,
114
- 19, 19, 19, 19, 19, 19, 19, 19,
115
- 19, 19, 19, 19, 19, 19, 19, 19,
116
- 19, 19, 19, 19, 19, 19, 19, 19,
117
- 19, 19, 19, 19, 19, 19, 19, 19,
118
- 19, 19, 19, 19, 19, 19, 19, 19,
119
- 19, 19, 19, 19, 19, 19, 19, 19,
120
- 19, 19, 23, 19, 19, 19, 19, 19,
121
- 19, 19, 19, 19, 19, 19, 19, 19,
122
- 19, 19, 19, 19, 19, 19, 19, 19,
123
- 19, 19, 19, 19, 19, 19, 19, 19,
124
- 19, 19, 19, 19, 19, 19, 1, 24,
125
- 1, 19, 1, 1, 1, 1, 1, 1,
116
+ 14, 14, 14, 14, 14, 14, 1, 1,
117
+ 1, 1, 1, 1, 1, 1, 1, 1,
118
+ 1, 1, 1, 1, 1, 1, 1, 1,
119
+ 1, 1, 1, 1, 1, 1, 1, 1,
120
+ 1, 1, 1, 1, 1, 1, 1, 1,
121
+ 1, 1, 1, 1, 1, 1, 1, 1,
122
+ 1, 1, 1, 1, 1, 1, 1, 1,
126
123
  1, 1, 1, 1, 1, 1, 1, 1,
127
124
  1, 1, 1, 1, 1, 1, 1, 1,
128
- 19, 1, 19, 19, 19, 19, 19, 19,
129
- 19, 19, 19, 19, 19, 19, 19, 19,
130
- 19, 19, 19, 19, 19, 19, 19, 19,
131
- 19, 19, 19, 19, 19, 19, 19, 19,
132
- 19, 19, 19, 19, 19, 19, 19, 19,
133
- 19, 19, 19, 19, 19, 19, 19, 19,
134
- 19, 19, 19, 19, 19, 19, 19, 19,
135
- 19, 19, 19, 19, 19, 19, 19, 19,
136
- 19, 19, 19, 19, 19, 19, 19, 19,
137
- 19, 19, 19, 19, 19, 19, 19, 19,
138
- 19, 19, 19, 19, 19, 19, 19, 19,
139
- 19, 19, 19, 19, 19, 19, 19, 19,
140
- 19, 19, 19, 19, 19, 19, 19, 19,
141
125
  19, 19, 19, 19, 19, 19, 19, 19,
142
126
  19, 19, 19, 19, 19, 19, 19, 19,
143
127
  19, 19, 19, 19, 19, 19, 19, 19,
144
- 19, 19, 1, 25, 1, 1, 1, 26,
128
+ 19, 19, 19, 19, 19, 19, 20, 21,
129
+ 21, 21, 21, 21, 21, 21, 21, 21,
130
+ 21, 21, 21, 22, 21, 21, 23, 24,
131
+ 24, 24, 25, 1, 26, 26, 26, 26,
132
+ 26, 26, 26, 26, 26, 1, 26, 26,
133
+ 27, 26, 26, 26, 26, 26, 26, 26,
134
+ 26, 26, 26, 26, 26, 26, 26, 26,
135
+ 26, 26, 26, 26, 26, 26, 26, 26,
136
+ 26, 26, 26, 28, 29, 26, 26, 26,
137
+ 26, 26, 26, 26, 26, 26, 26, 26,
138
+ 26, 26, 26, 26, 26, 26, 26, 26,
139
+ 26, 26, 26, 26, 26, 26, 26, 26,
140
+ 26, 26, 26, 26, 26, 26, 26, 26,
141
+ 26, 26, 26, 26, 26, 26, 26, 26,
142
+ 26, 26, 26, 26, 26, 26, 26, 30,
143
+ 26, 26, 26, 26, 26, 26, 26, 26,
144
+ 26, 26, 26, 26, 26, 26, 26, 26,
145
+ 26, 26, 26, 26, 26, 26, 26, 26,
146
+ 26, 26, 26, 26, 26, 26, 26, 26,
147
+ 26, 26, 26, 1, 1, 1, 1, 1,
148
+ 1, 1, 1, 1, 1, 1, 1, 1,
149
+ 1, 1, 1, 1, 1, 1, 1, 1,
150
+ 1, 1, 1, 1, 1, 1, 1, 1,
151
+ 1, 1, 1, 1, 1, 1, 1, 1,
152
+ 1, 1, 1, 1, 1, 1, 1, 1,
145
153
  1, 1, 1, 1, 1, 1, 1, 1,
146
154
  1, 1, 1, 1, 1, 1, 1, 1,
147
- 1, 1, 25, 27, 27, 27, 27, 27,
148
- 27, 27, 28, 1, 27, 27, 27, 27,
149
- 27, 1, 27, 27, 27, 27, 27, 27,
150
- 27, 27, 27, 27, 1, 29, 1, 1,
151
- 1, 1, 1, 27, 27, 27, 27, 27,
152
- 27, 27, 27, 27, 27, 27, 27, 27,
153
- 27, 27, 27, 27, 27, 27, 27, 27,
154
- 27, 27, 27, 27, 27, 1, 1, 1,
155
- 27, 27, 27, 27, 27, 27, 27, 27,
156
- 27, 27, 27, 27, 27, 27, 27, 27,
157
- 27, 27, 27, 27, 27, 27, 27, 27,
158
- 27, 27, 27, 27, 27, 27, 27, 27,
159
- 27, 1, 7, 1, 1, 1, 30, 1,
155
+ 1, 1, 1, 1, 1, 31, 31, 31,
156
+ 31, 31, 31, 31, 31, 31, 31, 31,
157
+ 31, 31, 31, 31, 31, 31, 31, 31,
158
+ 31, 31, 31, 31, 31, 31, 31, 31,
159
+ 31, 31, 31, 32, 33, 33, 33, 33,
160
+ 33, 33, 33, 33, 33, 33, 33, 33,
161
+ 34, 33, 33, 35, 36, 36, 36, 37,
162
+ 1, 38, 1, 26, 1, 1, 1, 1,
160
163
  1, 1, 1, 1, 1, 1, 1, 1,
161
164
  1, 1, 1, 1, 1, 1, 1, 1,
162
- 1, 7, 1, 1, 1, 1, 1, 1,
163
- 1, 31, 1, 1, 1, 1, 1, 1,
165
+ 1, 1, 26, 1, 26, 26, 26, 26,
166
+ 26, 26, 26, 26, 26, 26, 26, 26,
167
+ 26, 26, 26, 26, 26, 26, 26, 26,
168
+ 26, 26, 26, 26, 26, 26, 26, 26,
169
+ 26, 26, 26, 26, 26, 26, 26, 26,
170
+ 26, 26, 26, 26, 26, 26, 26, 26,
171
+ 26, 26, 26, 26, 26, 26, 26, 26,
172
+ 26, 26, 26, 26, 26, 26, 26, 26,
173
+ 26, 26, 26, 26, 26, 26, 26, 26,
174
+ 26, 26, 26, 26, 26, 26, 26, 26,
175
+ 26, 26, 26, 26, 26, 26, 26, 26,
176
+ 26, 26, 26, 26, 26, 26, 26, 26,
177
+ 26, 26, 26, 26, 26, 26, 26, 26,
178
+ 26, 26, 26, 26, 26, 26, 26, 26,
179
+ 26, 26, 26, 26, 26, 26, 26, 26,
180
+ 26, 26, 26, 26, 26, 26, 26, 26,
181
+ 26, 26, 26, 26, 1, 1, 1, 1,
164
182
  1, 1, 1, 1, 1, 1, 1, 1,
165
- 1, 1, 1, 1, 9, 1, 32, 1,
166
- 1, 1, 33, 1, 1, 1, 1, 1,
167
183
  1, 1, 1, 1, 1, 1, 1, 1,
168
- 1, 1, 1, 1, 1, 32, 1, 1,
169
- 1, 1, 1, 1, 1, 34, 1, 1,
170
184
  1, 1, 1, 1, 1, 1, 1, 1,
171
185
  1, 1, 1, 1, 1, 1, 1, 1,
172
- 35, 1, 9, 1, 1, 1, 36, 1,
173
186
  1, 1, 1, 1, 1, 1, 1, 1,
174
187
  1, 1, 1, 1, 1, 1, 1, 1,
175
- 1, 9, 1, 1, 1, 1, 1, 1,
176
- 1, 37, 1, 35, 1, 1, 1, 38,
177
188
  1, 1, 1, 1, 1, 1, 1, 1,
189
+ 1, 1, 1, 1, 1, 1, 31, 31,
190
+ 31, 31, 31, 31, 31, 31, 31, 31,
191
+ 31, 31, 31, 31, 31, 31, 31, 31,
192
+ 31, 31, 31, 31, 31, 31, 31, 31,
193
+ 31, 31, 31, 31, 32, 33, 33, 33,
194
+ 33, 33, 33, 33, 33, 33, 33, 33,
195
+ 33, 34, 33, 33, 35, 36, 36, 36,
196
+ 37, 1, 26, 26, 26, 26, 26, 26,
197
+ 26, 26, 26, 26, 26, 26, 26, 26,
198
+ 26, 26, 26, 26, 26, 26, 26, 26,
199
+ 26, 26, 26, 26, 26, 26, 26, 26,
200
+ 26, 26, 26, 26, 26, 26, 26, 26,
201
+ 26, 26, 26, 26, 26, 26, 26, 26,
202
+ 26, 26, 26, 26, 26, 26, 26, 26,
203
+ 26, 26, 26, 26, 26, 26, 26, 26,
204
+ 26, 26, 1, 31, 31, 31, 31, 31,
205
+ 31, 31, 31, 31, 31, 31, 31, 31,
206
+ 31, 31, 31, 31, 31, 31, 31, 31,
207
+ 31, 31, 31, 31, 31, 31, 31, 31,
208
+ 31, 31, 31, 1, 31, 31, 31, 31,
209
+ 31, 31, 31, 31, 31, 31, 31, 31,
210
+ 31, 31, 31, 31, 31, 31, 31, 31,
211
+ 31, 31, 31, 31, 31, 31, 31, 31,
212
+ 31, 31, 31, 31, 31, 31, 31, 31,
213
+ 31, 31, 31, 31, 31, 31, 31, 31,
214
+ 31, 31, 31, 31, 31, 31, 31, 31,
215
+ 31, 31, 31, 31, 31, 31, 31, 31,
216
+ 31, 31, 31, 31, 1, 31, 31, 31,
217
+ 31, 31, 31, 31, 31, 31, 31, 31,
218
+ 31, 31, 31, 31, 31, 31, 31, 31,
219
+ 31, 31, 31, 31, 31, 31, 31, 31,
220
+ 31, 31, 31, 31, 31, 1, 33, 33,
221
+ 33, 33, 33, 33, 33, 33, 33, 33,
222
+ 33, 33, 33, 33, 33, 33, 33, 33,
223
+ 33, 33, 33, 33, 33, 33, 33, 33,
224
+ 33, 33, 33, 33, 33, 33, 33, 33,
225
+ 33, 33, 33, 33, 33, 33, 33, 33,
226
+ 33, 33, 33, 33, 33, 33, 1, 33,
227
+ 33, 33, 33, 33, 33, 33, 33, 33,
228
+ 33, 33, 33, 33, 33, 33, 33, 33,
229
+ 33, 33, 33, 33, 33, 33, 33, 33,
230
+ 33, 33, 33, 33, 33, 33, 33, 33,
231
+ 33, 33, 33, 33, 33, 33, 33, 33,
232
+ 33, 33, 33, 33, 33, 33, 33, 33,
233
+ 33, 33, 33, 33, 33, 33, 33, 33,
234
+ 33, 33, 33, 33, 33, 33, 33, 1,
235
+ 33, 33, 33, 33, 33, 33, 33, 33,
236
+ 33, 33, 33, 33, 33, 33, 33, 33,
237
+ 1, 39, 1, 1, 1, 40, 1, 1,
178
238
  1, 1, 1, 1, 1, 1, 1, 1,
179
- 1, 1, 35, 1, 1, 1, 1, 1,
180
- 1, 1, 39, 1, 1, 0
239
+ 1, 1, 1, 1, 1, 1, 1, 1,
240
+ 39, 41, 41, 41, 41, 41, 41, 41,
241
+ 42, 1, 41, 41, 41, 41, 41, 1,
242
+ 41, 41, 41, 41, 41, 41, 41, 41,
243
+ 41, 41, 1, 43, 1, 1, 1, 1,
244
+ 1, 41, 41, 41, 41, 41, 41, 41,
245
+ 41, 41, 41, 41, 41, 41, 41, 41,
246
+ 41, 41, 41, 41, 41, 41, 41, 41,
247
+ 41, 41, 41, 1, 1, 1, 41, 41,
248
+ 41, 41, 41, 41, 41, 41, 41, 41,
249
+ 41, 41, 41, 41, 41, 41, 41, 41,
250
+ 41, 41, 41, 41, 41, 41, 41, 41,
251
+ 41, 41, 41, 41, 41, 41, 41, 1,
252
+ 7, 1, 1, 1, 44, 1, 1, 1,
253
+ 1, 1, 1, 1, 1, 1, 1, 1,
254
+ 1, 1, 1, 1, 1, 1, 1, 7,
255
+ 1, 1, 1, 1, 1, 1, 1, 45,
256
+ 1, 1, 1, 1, 1, 1, 1, 1,
257
+ 1, 1, 1, 1, 1, 1, 1, 1,
258
+ 1, 1, 9, 1, 46, 1, 1, 1,
259
+ 47, 1, 1, 1, 1, 1, 1, 1,
260
+ 1, 1, 1, 1, 1, 1, 1, 1,
261
+ 1, 1, 1, 46, 1, 1, 1, 1,
262
+ 1, 1, 1, 48, 1, 1, 1, 1,
263
+ 1, 1, 1, 1, 1, 1, 1, 1,
264
+ 1, 1, 1, 1, 1, 1, 49, 1,
265
+ 9, 1, 1, 1, 50, 1, 1, 1,
266
+ 1, 1, 1, 1, 1, 1, 1, 1,
267
+ 1, 1, 1, 1, 1, 1, 1, 9,
268
+ 1, 1, 1, 1, 1, 1, 1, 51,
269
+ 1, 49, 1, 1, 1, 52, 1, 1,
270
+ 1, 1, 1, 1, 1, 1, 1, 1,
271
+ 1, 1, 1, 1, 1, 1, 1, 1,
272
+ 49, 1, 1, 1, 1, 1, 1, 1,
273
+ 53, 1, 1, 0
181
274
  ]
182
275
 
183
276
  class << self
@@ -185,11 +278,13 @@ class << self
185
278
  private :_trans_targs, :_trans_targs=
186
279
  end
187
280
  self._trans_targs = [
188
- 1, 0, 2, 14, 8, 3, 5, 15,
189
- 7, 17, 1, 2, 14, 8, 10, 11,
190
- 10, 19, 13, 10, 11, 10, 19, 13,
191
- 12, 15, 4, 14, 16, 17, 4, 16,
192
- 15, 4, 16, 17, 6, 18, 6, 18
281
+ 1, 0, 2, 21, 8, 3, 5, 22,
282
+ 7, 24, 1, 2, 21, 8, 10, 11,
283
+ 10, 26, 13, 14, 15, 16, 17, 18,
284
+ 19, 20, 10, 11, 10, 26, 13, 14,
285
+ 15, 16, 17, 18, 19, 20, 12, 22,
286
+ 4, 21, 23, 24, 4, 23, 22, 4,
287
+ 23, 24, 6, 25, 6, 25
193
288
  ]
194
289
 
195
290
  class << self
@@ -199,9 +294,11 @@ end
199
294
  self._trans_actions = [
200
295
  0, 0, 0, 1, 2, 0, 0, 0,
201
296
  0, 0, 3, 3, 4, 5, 6, 6,
202
- 7, 8, 6, 0, 0, 2, 9, 0,
203
- 0, 10, 10, 0, 11, 10, 0, 2,
204
- 3, 3, 5, 3, 0, 2, 3, 5
297
+ 7, 8, 6, 6, 6, 6, 6, 6,
298
+ 6, 6, 0, 0, 2, 9, 0, 0,
299
+ 0, 0, 0, 0, 0, 0, 0, 10,
300
+ 10, 0, 11, 10, 0, 2, 3, 3,
301
+ 5, 3, 0, 2, 3, 5
205
302
  ]
206
303
 
207
304
  class << self
@@ -210,8 +307,9 @@ class << self
210
307
  end
211
308
  self._eof_actions = [
212
309
  0, 0, 0, 0, 0, 0, 0, 0,
213
- 0, 0, 0, 0, 0, 0, 10, 0,
214
- 3, 0, 3, 0
310
+ 0, 0, 0, 0, 0, 0, 0, 0,
311
+ 0, 0, 0, 0, 0, 10, 0, 3,
312
+ 0, 3, 0
215
313
  ]
216
314
 
217
315
  class << self
@@ -221,7 +319,7 @@ self.start = 1;
221
319
  class << self
222
320
  attr_accessor :first_final
223
321
  end
224
- self.first_final = 14;
322
+ self.first_final = 21;
225
323
  class << self
226
324
  attr_accessor :error
227
325
  end
@@ -239,6 +337,8 @@ self.en_main = 1;
239
337
 
240
338
 
241
339
  def self.parse(data)
340
+ data = data.dup.force_encoding(Encoding::ASCII_8BIT) if data.respond_to?(:force_encoding)
341
+
242
342
  content_transfer_encoding = ContentTransferEncodingStruct.new('')
243
343
  return content_transfer_encoding if Mail::Utilities.blank?(data)
244
344
 
@@ -300,7 +400,7 @@ begin
300
400
  encoding_s = p end
301
401
  when 10 then
302
402
  begin
303
- content_transfer_encoding.encoding = data[encoding_s..(p-1)].downcase end
403
+ content_transfer_encoding.encoding = chars(data, encoding_s, p-1).downcase end
304
404
  when 3 then
305
405
  begin
306
406
  end
@@ -328,7 +428,7 @@ begin
328
428
  end
329
429
  when 11 then
330
430
  begin
331
- content_transfer_encoding.encoding = data[encoding_s..(p-1)].downcase end
431
+ content_transfer_encoding.encoding = chars(data, encoding_s, p-1).downcase end
332
432
  begin
333
433
  begin
334
434
  stack[top] = cs
@@ -397,7 +497,7 @@ begin
397
497
  case _eof_actions[cs]
398
498
  when 10 then
399
499
  begin
400
- content_transfer_encoding.encoding = data[encoding_s..(p-1)].downcase end
500
+ content_transfer_encoding.encoding = chars(data, encoding_s, p-1).downcase end
401
501
  when 3 then
402
502
  begin
403
503
  end
@@ -412,8 +512,8 @@ end
412
512
  end
413
513
 
414
514
 
415
- if p != eof || cs < 14
416
- raise Mail::Field::ParseError.new(Mail::ContentTransferEncodingElement, data, "Only able to parse up to #{data[0..p]}")
515
+ if p != eof || cs < 21
516
+ raise Mail::Field::IncompleteParseError.new(Mail::ContentTransferEncodingElement, data, p)
417
517
  end
418
518
 
419
519
  content_transfer_encoding
@@ -1,11 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
  require 'mail/utilities'
3
+ require 'mail/parser_tools'
3
4
 
4
5
  %%{
5
6
  machine content_transfer_encoding;
7
+ alphtype int;
6
8
 
7
9
  action encoding_s { encoding_s = p }
8
- action encoding_e { content_transfer_encoding.encoding = data[encoding_s..(p-1)].downcase }
10
+ action encoding_e { content_transfer_encoding.encoding = chars(data, encoding_s, p-1).downcase }
9
11
 
10
12
  # No-op actions
11
13
  action comment_e { }
@@ -29,11 +31,15 @@ require 'mail/utilities'
29
31
 
30
32
  module Mail::Parsers
31
33
  module ContentTransferEncodingParser
34
+ extend Mail::ParserTools
35
+
32
36
  ContentTransferEncodingStruct = Struct.new(:encoding, :error)
33
37
 
34
38
  %%write data noprefix;
35
39
 
36
40
  def self.parse(data)
41
+ data = data.dup.force_encoding(Encoding::ASCII_8BIT) if data.respond_to?(:force_encoding)
42
+
37
43
  content_transfer_encoding = ContentTransferEncodingStruct.new('')
38
44
  return content_transfer_encoding if Mail::Utilities.blank?(data)
39
45
 
@@ -49,7 +55,7 @@ module Mail::Parsers
49
55
  %%write exec;
50
56
 
51
57
  if p != eof || cs < %%{ write first_final; }%%
52
- raise Mail::Field::ParseError.new(Mail::ContentTransferEncodingElement, data, "Only able to parse up to #{data[0..p]}")
58
+ raise Mail::Field::IncompleteParseError.new(Mail::ContentTransferEncodingElement, data, p)
53
59
  end
54
60
 
55
61
  content_transfer_encoding