mail 2.6.6 → 2.7.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.rdoc +25 -6
  3. data/Dependencies.txt +0 -1
  4. data/Gemfile +5 -8
  5. data/MIT-LICENSE +1 -1
  6. data/README.md +22 -11
  7. data/Rakefile +0 -6
  8. data/lib/mail.rb +2 -10
  9. data/lib/mail/attachments_list.rb +3 -2
  10. data/lib/mail/body.rb +3 -3
  11. data/lib/mail/core_extensions/smtp.rb +19 -16
  12. data/lib/mail/core_extensions/string.rb +0 -4
  13. data/lib/mail/elements/address.rb +9 -4
  14. data/lib/mail/elements/address_list.rb +10 -18
  15. data/lib/mail/elements/content_disposition_element.rb +8 -15
  16. data/lib/mail/elements/content_location_element.rb +5 -10
  17. data/lib/mail/elements/content_transfer_encoding_element.rb +5 -10
  18. data/lib/mail/elements/content_type_element.rb +8 -19
  19. data/lib/mail/elements/date_time_element.rb +6 -14
  20. data/lib/mail/elements/envelope_from_element.rb +14 -21
  21. data/lib/mail/elements/message_ids_element.rb +8 -12
  22. data/lib/mail/elements/mime_version_element.rb +6 -14
  23. data/lib/mail/elements/phrase_list.rb +6 -9
  24. data/lib/mail/elements/received_element.rb +9 -15
  25. data/lib/mail/encodings.rb +12 -14
  26. data/lib/mail/field.rb +7 -4
  27. data/lib/mail/fields/common/parameter_hash.rb +1 -1
  28. data/lib/mail/fields/content_type_field.rb +2 -7
  29. data/lib/mail/fields/unstructured_field.rb +2 -2
  30. data/lib/mail/header.rb +1 -0
  31. data/lib/mail/message.rb +23 -25
  32. data/lib/mail/multibyte.rb +51 -0
  33. data/lib/mail/multibyte/chars.rb +27 -27
  34. data/lib/mail/network/delivery_methods/exim.rb +10 -6
  35. data/lib/mail/network/delivery_methods/sendmail.rb +2 -6
  36. data/lib/mail/network/delivery_methods/smtp.rb +14 -6
  37. data/lib/mail/parsers.rb +16 -24
  38. data/lib/mail/parsers/address_lists_parser.rb +15321 -112
  39. data/lib/mail/parsers/address_lists_parser.rl +166 -0
  40. data/lib/mail/parsers/content_disposition_parser.rb +698 -55
  41. data/lib/mail/parsers/content_disposition_parser.rl +76 -0
  42. data/lib/mail/parsers/content_location_parser.rb +565 -23
  43. data/lib/mail/parsers/content_location_parser.rl +65 -0
  44. data/lib/mail/parsers/content_transfer_encoding_parser.rb +410 -22
  45. data/lib/mail/parsers/content_transfer_encoding_parser.rl +58 -0
  46. data/lib/mail/parsers/content_type_parser.rb +841 -54
  47. data/lib/mail/parsers/content_type_parser.rl +77 -0
  48. data/lib/mail/parsers/date_time_parser.rb +773 -26
  49. data/lib/mail/parsers/date_time_parser.rl +56 -0
  50. data/lib/mail/parsers/envelope_from_parser.rb +2051 -36
  51. data/lib/mail/parsers/envelope_from_parser.rl +76 -0
  52. data/lib/mail/parsers/message_ids_parser.rb +1494 -25
  53. data/lib/mail/parsers/message_ids_parser.rl +76 -0
  54. data/lib/mail/parsers/mime_version_parser.rb +393 -26
  55. data/lib/mail/parsers/mime_version_parser.rl +55 -0
  56. data/lib/mail/parsers/phrase_lists_parser.rb +529 -19
  57. data/lib/mail/parsers/phrase_lists_parser.rl +77 -0
  58. data/lib/mail/parsers/received_parser.rb +4711 -38
  59. data/lib/mail/parsers/received_parser.rl +78 -0
  60. data/lib/mail/parsers/rfc2045_content_transfer_encoding.rl +12 -0
  61. data/lib/mail/parsers/rfc2045_content_type.rl +24 -0
  62. data/lib/mail/parsers/rfc2045_mime.rl +15 -0
  63. data/lib/mail/parsers/rfc2183_content_disposition.rl +14 -0
  64. data/lib/mail/parsers/rfc5234_abnf_core_rules.rl +16 -0
  65. data/lib/mail/parsers/rfc5322.rl +57 -0
  66. data/lib/mail/parsers/rfc5322_address.rl +70 -0
  67. data/lib/mail/parsers/{ragel/date_time.rl → rfc5322_date_time.rl} +7 -1
  68. data/lib/mail/parsers/rfc5322_lexical_tokens.rl +56 -0
  69. data/lib/mail/part.rb +1 -1
  70. data/lib/mail/parts_list.rb +5 -6
  71. data/lib/mail/utilities.rb +4 -2
  72. data/lib/mail/version.rb +3 -3
  73. data/lib/mail/version_specific/ruby_1_8.rb +28 -2
  74. data/lib/mail/version_specific/ruby_1_9.rb +48 -8
  75. metadata +28 -45
  76. data/lib/mail/core_extensions/string/access.rb +0 -146
  77. data/lib/mail/core_extensions/string/multibyte.rb +0 -79
  78. data/lib/mail/parsers/ragel.rb +0 -18
  79. data/lib/mail/parsers/ragel/common.rl +0 -185
  80. data/lib/mail/parsers/ragel/parser_info.rb +0 -61
  81. data/lib/mail/parsers/ragel/ruby.rb +0 -40
  82. data/lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb +0 -14864
  83. data/lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb.rl +0 -37
  84. data/lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb +0 -751
  85. data/lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb.rl +0 -37
  86. data/lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb +0 -614
  87. data/lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb.rl +0 -37
  88. data/lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb +0 -447
  89. data/lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb.rl +0 -37
  90. data/lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb +0 -825
  91. data/lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb.rl +0 -37
  92. data/lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb +0 -817
  93. data/lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb.rl +0 -37
  94. data/lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb +0 -2149
  95. data/lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb.rl +0 -37
  96. data/lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb +0 -1570
  97. data/lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb.rl +0 -37
  98. data/lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb +0 -440
  99. data/lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb.rl +0 -37
  100. data/lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb +0 -564
  101. data/lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb.rl +0 -37
  102. data/lib/mail/parsers/ragel/ruby/machines/rb_actions.rl +0 -51
  103. data/lib/mail/parsers/ragel/ruby/machines/received_machine.rb +0 -5144
  104. data/lib/mail/parsers/ragel/ruby/machines/received_machine.rb.rl +0 -37
  105. data/lib/mail/parsers/ragel/ruby/parser.rb.rl.erb +0 -37
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+ require 'mail/utilities'
3
+
4
+ %%{
5
+ machine content_disposition;
6
+
7
+ # Disposition Type
8
+ action disp_type_s { disp_type_s = p }
9
+ action disp_type_e { content_disposition.disposition_type = data[disp_type_s..(p-1)].downcase }
10
+
11
+ # Parameter Attribute
12
+ action param_attr_s { param_attr_s = p }
13
+ action param_attr_e { param_attr = data[param_attr_s..(p-1)] }
14
+
15
+ # Quoted String
16
+ action qstr_s { qstr_s = p }
17
+ action qstr_e { qstr = data[qstr_s..(p-1)] }
18
+
19
+ # Parameter Value
20
+ action param_val_s { param_val_s = p }
21
+ action param_val_e {
22
+ if param_attr.nil?
23
+ raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, data, "no attribute for value")
24
+ end
25
+
26
+ # Use quoted string value if one exists, otherwise use parameter value
27
+ value = qstr || data[param_val_s..(p-1)]
28
+
29
+ content_disposition.parameters << { param_attr => value }
30
+ param_attr = nil
31
+ qstr = nil
32
+ }
33
+
34
+ # No-op actions
35
+ action comment_e { }
36
+ action comment_s { }
37
+ action phrase_e { }
38
+ action phrase_s { }
39
+ action main_type_e { }
40
+ action main_type_s { }
41
+ action sub_type_e { }
42
+ action sub_type_s { }
43
+
44
+ include rfc2183_content_disposition "rfc2183_content_disposition.rl";
45
+ main := disposition;
46
+ }%%
47
+
48
+ module Mail::Parsers
49
+ module ContentDispositionParser
50
+ ContentDispositionStruct = Struct.new(:disposition_type, :parameters, :error)
51
+
52
+ %%write data noprefix;
53
+
54
+ def self.parse(data)
55
+ content_disposition = ContentDispositionStruct.new('', [])
56
+ return content_disposition if Mail::Utilities.blank?(data)
57
+
58
+ # Parser state
59
+ disp_type_s = param_attr_s = param_attr = qstr_s = qstr = param_val_s = nil
60
+
61
+ # 5.1 Variables Used by Ragel
62
+ p = 0
63
+ eof = pe = data.length
64
+ stack = []
65
+
66
+ %%write init;
67
+ %%write exec;
68
+
69
+ if p != eof || cs < %%{ write first_final; }%%
70
+ raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, data, "Only able to parse up to #{data[0..p]}")
71
+ end
72
+
73
+ content_disposition
74
+ end
75
+ end
76
+ end
@@ -1,35 +1,577 @@
1
+
1
2
  # frozen_string_literal: true
3
+ require 'mail/utilities'
4
+
5
+
6
+
7
+
2
8
  module Mail::Parsers
3
- class ContentLocationParser
4
- def parse(s)
9
+ module ContentLocationParser
10
+ ContentLocationStruct = Struct.new(:location, :error)
11
+
12
+
13
+ class << self
14
+ attr_accessor :_trans_keys
15
+ private :_trans_keys, :_trans_keys=
16
+ end
17
+ self._trans_keys = [
18
+ 0, 0, 9, 126, 10, 10,
19
+ 9, 32, 10, 10, 9,
20
+ 32, 1, 127, 10, 10,
21
+ 9, 32, 0, 127, 10, 10,
22
+ 9, 32, 9, 126, 1,
23
+ 127, 1, 127, 10, 10,
24
+ 9, 32, 0, 127, 9, 126,
25
+ 9, 40, 9, 40, 1,
26
+ 127, 1, 127, 1, 127,
27
+ 1, 127, 9, 126, 0, 0,
28
+ 0
29
+ ]
30
+
31
+ class << self
32
+ attr_accessor :_key_spans
33
+ private :_key_spans, :_key_spans=
34
+ end
35
+ self._key_spans = [
36
+ 0, 118, 1, 24, 1, 24, 127, 1,
37
+ 24, 128, 1, 24, 118, 127, 127, 1,
38
+ 24, 128, 118, 32, 32, 127, 127, 127,
39
+ 127, 118, 0
40
+ ]
41
+
42
+ class << self
43
+ attr_accessor :_index_offsets
44
+ private :_index_offsets, :_index_offsets=
45
+ end
46
+ self._index_offsets = [
47
+ 0, 0, 119, 121, 146, 148, 173, 301,
48
+ 303, 328, 457, 459, 484, 603, 731, 859,
49
+ 861, 886, 1015, 1134, 1167, 1200, 1328, 1456,
50
+ 1584, 1712, 1831
51
+ ]
52
+
53
+ class << self
54
+ attr_accessor :_indicies
55
+ private :_indicies, :_indicies=
56
+ end
57
+ self._indicies = [
58
+ 0, 1, 1, 1, 2, 1, 1, 1,
59
+ 1, 1, 1, 1, 1, 1, 1, 1,
60
+ 1, 1, 1, 1, 1, 1, 1, 0,
61
+ 3, 4, 3, 3, 3, 3, 3, 5,
62
+ 1, 3, 3, 3, 3, 3, 1, 3,
63
+ 3, 3, 3, 3, 3, 3, 3, 3,
64
+ 3, 1, 1, 1, 3, 1, 1, 1,
65
+ 3, 3, 3, 3, 3, 3, 3, 3,
66
+ 3, 3, 3, 3, 3, 3, 3, 3,
67
+ 3, 3, 3, 3, 3, 3, 3, 3,
68
+ 3, 3, 1, 1, 1, 3, 3, 3,
69
+ 3, 3, 3, 3, 3, 3, 3, 3,
70
+ 3, 3, 3, 3, 3, 3, 3, 3,
71
+ 3, 3, 3, 3, 3, 3, 3, 3,
72
+ 3, 3, 3, 3, 3, 3, 1, 6,
73
+ 1, 0, 1, 1, 1, 1, 1, 1,
74
+ 1, 1, 1, 1, 1, 1, 1, 1,
75
+ 1, 1, 1, 1, 1, 1, 1, 1,
76
+ 0, 1, 7, 1, 8, 1, 1, 1,
77
+ 1, 1, 1, 1, 1, 1, 1, 1,
78
+ 1, 1, 1, 1, 1, 1, 1, 1,
79
+ 1, 1, 1, 8, 1, 9, 9, 9,
80
+ 9, 9, 9, 9, 9, 9, 1, 9,
81
+ 9, 10, 9, 9, 9, 9, 9, 9,
82
+ 9, 9, 9, 9, 9, 9, 9, 9,
83
+ 9, 9, 9, 9, 9, 9, 11, 9,
84
+ 9, 9, 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1, 1, 1,
120
+ 1, 1, 1, 1, 1, 1, 1, 1,
121
+ 1, 1, 1, 16, 18, 19, 18, 18,
122
+ 18, 18, 18, 20, 1, 18, 18, 18,
123
+ 18, 18, 1, 18, 18, 18, 18, 18,
124
+ 18, 18, 18, 18, 18, 1, 1, 1,
125
+ 18, 1, 1, 1, 18, 18, 18, 18,
126
+ 18, 18, 18, 18, 18, 18, 18, 18,
127
+ 18, 18, 18, 18, 18, 18, 18, 18,
128
+ 18, 18, 18, 18, 18, 18, 1, 1,
129
+ 1, 18, 18, 18, 18, 18, 18, 18,
130
+ 18, 18, 18, 18, 18, 18, 18, 18,
131
+ 18, 18, 18, 18, 18, 18, 18, 18,
132
+ 18, 18, 18, 18, 18, 18, 18, 18,
133
+ 18, 18, 1, 21, 21, 21, 21, 21,
134
+ 21, 21, 21, 21, 1, 21, 21, 22,
135
+ 21, 21, 21, 21, 21, 21, 21, 21,
136
+ 21, 21, 21, 21, 21, 21, 21, 21,
137
+ 21, 21, 21, 21, 21, 21, 21, 21,
138
+ 21, 21, 23, 24, 21, 21, 21, 21,
139
+ 21, 21, 21, 21, 21, 21, 21, 21,
140
+ 21, 21, 21, 21, 21, 21, 21, 21,
141
+ 21, 21, 21, 21, 21, 21, 21, 21,
142
+ 21, 21, 21, 21, 21, 21, 21, 21,
143
+ 21, 21, 21, 21, 21, 21, 21, 21,
144
+ 21, 21, 21, 21, 21, 21, 25, 21,
145
+ 21, 21, 21, 21, 21, 21, 21, 21,
146
+ 21, 21, 21, 21, 21, 21, 21, 21,
147
+ 21, 21, 21, 21, 21, 21, 21, 21,
148
+ 21, 21, 21, 21, 21, 21, 21, 21,
149
+ 21, 21, 1, 26, 26, 26, 26, 26,
150
+ 26, 26, 26, 26, 1, 26, 26, 27,
151
+ 26, 26, 26, 26, 26, 26, 26, 26,
152
+ 26, 26, 26, 26, 26, 26, 26, 26,
153
+ 26, 26, 26, 26, 26, 26, 26, 26,
154
+ 26, 26, 28, 29, 26, 26, 26, 26,
155
+ 26, 26, 26, 26, 26, 26, 26, 26,
156
+ 26, 26, 26, 26, 26, 26, 26, 26,
157
+ 26, 26, 26, 26, 26, 26, 26, 26,
158
+ 26, 26, 26, 26, 26, 26, 26, 26,
159
+ 26, 26, 26, 26, 26, 26, 26, 26,
160
+ 26, 26, 26, 26, 26, 26, 30, 26,
161
+ 26, 26, 26, 26, 26, 26, 26, 26,
162
+ 26, 26, 26, 26, 26, 26, 26, 26,
163
+ 26, 26, 26, 26, 26, 26, 26, 26,
164
+ 26, 26, 26, 26, 26, 26, 26, 26,
165
+ 26, 26, 1, 31, 1, 26, 1, 1,
166
+ 1, 1, 1, 1, 1, 1, 1, 1,
167
+ 1, 1, 1, 1, 1, 1, 1, 1,
168
+ 1, 1, 1, 1, 26, 1, 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, 26, 26, 26, 26,
182
+ 26, 26, 26, 26, 26, 26, 26, 26,
183
+ 26, 26, 26, 26, 26, 26, 26, 26,
184
+ 26, 26, 26, 26, 26, 26, 1, 32,
185
+ 1, 1, 1, 33, 1, 1, 1, 1,
186
+ 1, 1, 1, 1, 1, 1, 1, 1,
187
+ 1, 1, 1, 1, 1, 1, 32, 34,
188
+ 34, 34, 34, 34, 34, 34, 35, 1,
189
+ 34, 34, 34, 34, 34, 1, 34, 34,
190
+ 34, 34, 34, 34, 34, 34, 34, 34,
191
+ 1, 1, 1, 34, 1, 1, 1, 34,
192
+ 34, 34, 34, 34, 34, 34, 34, 34,
193
+ 34, 34, 34, 34, 34, 34, 34, 34,
194
+ 34, 34, 34, 34, 34, 34, 34, 34,
195
+ 34, 1, 1, 1, 34, 34, 34, 34,
196
+ 34, 34, 34, 34, 34, 34, 34, 34,
197
+ 34, 34, 34, 34, 34, 34, 34, 34,
198
+ 34, 34, 34, 34, 34, 34, 34, 34,
199
+ 34, 34, 34, 34, 34, 1, 8, 1,
200
+ 1, 1, 36, 1, 1, 1, 1, 1,
201
+ 1, 1, 1, 1, 1, 1, 1, 1,
202
+ 1, 1, 1, 1, 1, 8, 1, 1,
203
+ 1, 1, 1, 1, 1, 37, 1, 38,
204
+ 1, 1, 1, 39, 1, 1, 1, 1,
205
+ 1, 1, 1, 1, 1, 1, 1, 1,
206
+ 1, 1, 1, 1, 1, 1, 38, 1,
207
+ 1, 1, 1, 1, 1, 1, 40, 1,
208
+ 41, 41, 41, 41, 41, 41, 41, 41,
209
+ 42, 1, 41, 41, 43, 41, 41, 41,
210
+ 41, 41, 41, 41, 41, 41, 41, 41,
211
+ 41, 41, 41, 41, 41, 41, 41, 42,
212
+ 44, 45, 44, 44, 44, 44, 44, 46,
213
+ 41, 44, 44, 44, 44, 44, 41, 44,
214
+ 44, 44, 44, 44, 44, 44, 44, 44,
215
+ 44, 41, 41, 41, 44, 41, 41, 41,
216
+ 44, 44, 44, 44, 44, 44, 44, 44,
217
+ 44, 44, 44, 44, 44, 44, 44, 44,
218
+ 44, 44, 44, 44, 44, 44, 44, 44,
219
+ 44, 44, 41, 47, 41, 44, 44, 44,
220
+ 44, 44, 44, 44, 44, 44, 44, 44,
221
+ 44, 44, 44, 44, 44, 44, 44, 44,
222
+ 44, 44, 44, 44, 44, 44, 44, 44,
223
+ 44, 44, 44, 44, 44, 44, 41, 1,
224
+ 9, 9, 9, 9, 9, 9, 9, 9,
225
+ 15, 1, 9, 9, 48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,
261
+ 9, 55, 55, 55, 55, 55, 9, 55,
262
+ 55, 55, 55, 55, 55, 55, 55, 55,
263
+ 55, 9, 9, 9, 55, 9, 9, 9,
264
+ 55, 55, 55, 55, 55, 55, 55, 55,
265
+ 55, 55, 55, 55, 55, 55, 55, 55,
266
+ 55, 55, 55, 55, 55, 55, 55, 55,
267
+ 55, 55, 9, 12, 9, 55, 55, 55,
268
+ 55, 55, 55, 55, 55, 55, 55, 55,
269
+ 55, 55, 55, 55, 55, 55, 55, 55,
270
+ 55, 55, 55, 55, 55, 55, 55, 55,
271
+ 55, 55, 55, 55, 55, 55, 9, 1,
272
+ 32, 1, 1, 1, 33, 1, 1, 1,
273
+ 1, 1, 1, 1, 1, 1, 1, 1,
274
+ 1, 1, 1, 1, 1, 1, 1, 32,
275
+ 34, 34, 34, 34, 34, 34, 34, 58,
276
+ 1, 34, 34, 34, 34, 34, 1, 34,
277
+ 34, 34, 34, 34, 34, 34, 34, 34,
278
+ 34, 1, 1, 1, 34, 1, 1, 1,
279
+ 34, 34, 34, 34, 34, 34, 34, 34,
280
+ 34, 34, 34, 34, 34, 34, 34, 34,
281
+ 34, 34, 34, 34, 34, 34, 34, 34,
282
+ 34, 34, 1, 1, 1, 34, 34, 34,
283
+ 34, 34, 34, 34, 34, 34, 34, 34,
284
+ 34, 34, 34, 34, 34, 34, 34, 34,
285
+ 34, 34, 34, 34, 34, 34, 34, 34,
286
+ 34, 34, 34, 34, 34, 34, 1, 1,
287
+ 0
288
+ ]
289
+
290
+ class << self
291
+ attr_accessor :_trans_targs
292
+ private :_trans_targs, :_trans_targs=
293
+ end
294
+ self._trans_targs = [
295
+ 1, 0, 2, 18, 21, 12, 3, 5,
296
+ 19, 6, 7, 19, 9, 8, 11, 22,
297
+ 1, 2, 18, 21, 12, 14, 15, 14,
298
+ 26, 17, 14, 15, 14, 26, 17, 16,
299
+ 19, 4, 18, 20, 4, 20, 19, 4,
300
+ 20, 6, 22, 10, 24, 25, 23, 9,
301
+ 10, 23, 22, 10, 23, 22, 10, 24,
302
+ 25, 23, 20
303
+ ]
304
+
305
+ class << self
306
+ attr_accessor :_trans_actions
307
+ private :_trans_actions, :_trans_actions=
308
+ end
309
+ self._trans_actions = [
310
+ 0, 0, 0, 1, 1, 2, 0, 0,
311
+ 0, 0, 0, 3, 0, 0, 0, 0,
312
+ 4, 4, 5, 5, 6, 7, 7, 8,
313
+ 9, 7, 0, 0, 2, 10, 0, 0,
314
+ 11, 11, 0, 12, 0, 2, 4, 4,
315
+ 6, 13, 14, 14, 13, 15, 16, 13,
316
+ 0, 2, 4, 4, 6, 11, 11, 0,
317
+ 3, 12, 17
318
+ ]
319
+
320
+ class << self
321
+ attr_accessor :_eof_actions
322
+ private :_eof_actions, :_eof_actions=
323
+ end
324
+ self._eof_actions = [
325
+ 0, 0, 0, 0, 0, 0, 0, 0,
326
+ 0, 0, 0, 0, 0, 0, 0, 0,
327
+ 0, 0, 11, 0, 4, 11, 0, 4,
328
+ 11, 11, 0
329
+ ]
330
+
331
+ class << self
332
+ attr_accessor :start
333
+ end
334
+ self.start = 1;
335
+ class << self
336
+ attr_accessor :first_final
337
+ end
338
+ self.first_final = 18;
339
+ class << self
340
+ attr_accessor :error
341
+ end
342
+ self.error = 0;
343
+
344
+ class << self
345
+ attr_accessor :en_comment_tail
346
+ end
347
+ self.en_comment_tail = 13;
348
+ class << self
349
+ attr_accessor :en_main
350
+ end
351
+ self.en_main = 1;
352
+
353
+
354
+
355
+ def self.parse(data)
5
356
  content_location = ContentLocationStruct.new(nil)
6
- if Mail::Utilities.blank?(s)
7
- return content_location
8
- end
357
+ return content_location if Mail::Utilities.blank?(data)
9
358
 
10
- actions, error = Ragel.parse(:content_location, s)
11
- if error
12
- raise Mail::Field::ParseError.new(Mail::ContentLocationElement, s, error)
13
- end
359
+ # Parser state
360
+ disp_type_s = param_attr_s = param_attr = qstr_s = qstr = param_val_s = nil
14
361
 
15
- qstr_s = token_string_s = nil
16
- actions.each_slice(2) do |action_id, p|
17
- action = Mail::Parsers::Ragel::ACTIONS[action_id]
18
- case action
362
+ # 5.1 Variables Used by Ragel
363
+ p = 0
364
+ eof = pe = data.length
365
+ stack = []
19
366
 
20
- # Quoted String.
21
- when :qstr_s then qstr_s = p
22
- when :qstr_e then content_location.location = s[qstr_s..(p-1)]
367
+
368
+ begin
369
+ p ||= 0
370
+ pe ||= data.length
371
+ cs = start
372
+ top = 0
373
+ end
23
374
 
24
- # Token String
25
- when :token_string_s then token_string_s = p
26
- when :token_string_e
27
- content_location.location = s[token_string_s..(p-1)]
375
+
376
+ begin
377
+ testEof = false
378
+ _slen, _trans, _keys, _inds, _acts, _nacts = nil
379
+ _goto_level = 0
380
+ _resume = 10
381
+ _eof_trans = 15
382
+ _again = 20
383
+ _test_eof = 30
384
+ _out = 40
385
+ while true
386
+ if _goto_level <= 0
387
+ if p == pe
388
+ _goto_level = _test_eof
389
+ next
390
+ end
391
+ if cs == 0
392
+ _goto_level = _out
393
+ next
394
+ end
395
+ end
396
+ if _goto_level <= _resume
397
+ _keys = cs << 1
398
+ _inds = _index_offsets[cs]
399
+ _slen = _key_spans[cs]
400
+ _wide = data[p].ord
401
+ _trans = if ( _slen > 0 &&
402
+ _trans_keys[_keys] <= _wide &&
403
+ _wide <= _trans_keys[_keys + 1]
404
+ ) then
405
+ _indicies[ _inds + _wide - _trans_keys[_keys] ]
406
+ else
407
+ _indicies[ _inds + _slen ]
408
+ end
409
+ cs = _trans_targs[_trans]
410
+ if _trans_actions[_trans] != 0
411
+ case _trans_actions[_trans]
412
+ when 13 then
413
+ begin
414
+ qstr_s = p end
415
+ when 3 then
416
+ begin
417
+ content_location.location = data[qstr_s..(p-1)] end
418
+ when 1 then
419
+ begin
420
+ token_string_s = p end
421
+ when 11 then
422
+ begin
423
+ content_location.location = data[token_string_s..(p-1)] end
424
+ when 4 then
425
+ begin
426
+ end
427
+ when 7 then
428
+ begin
429
+ end
430
+ when 2 then
431
+ begin
432
+ begin
433
+ stack[top] = cs
434
+ top+= 1
435
+ cs = 13
436
+ _goto_level = _again
437
+ next
438
+ end
439
+ end
440
+ when 10 then
441
+ begin
442
+ begin
443
+ top -= 1
444
+ cs = stack[top]
445
+ _goto_level = _again
446
+ next
447
+ end
448
+ end
449
+ when 15 then
450
+ begin
451
+ qstr_s = p end
452
+ begin
453
+ content_location.location = data[qstr_s..(p-1)] end
454
+ when 14 then
455
+ begin
456
+ qstr_s = p end
457
+ begin
458
+ content_location.location = data[token_string_s..(p-1)] end
459
+ when 12 then
460
+ begin
461
+ content_location.location = data[token_string_s..(p-1)] end
462
+ begin
463
+ begin
464
+ stack[top] = cs
465
+ top+= 1
466
+ cs = 13
467
+ _goto_level = _again
468
+ next
469
+ end
470
+ end
471
+ when 5 then
472
+ begin
473
+ end
474
+ begin
475
+ token_string_s = p end
476
+ when 6 then
477
+ begin
478
+ end
479
+ begin
480
+ begin
481
+ stack[top] = cs
482
+ top+= 1
483
+ cs = 13
484
+ _goto_level = _again
485
+ next
486
+ end
487
+ end
488
+ when 8 then
489
+ begin
490
+ end
491
+ begin
492
+ begin
493
+ stack[top] = cs
494
+ top+= 1
495
+ cs = 13
496
+ _goto_level = _again
497
+ next
498
+ end
499
+ end
500
+ when 9 then
501
+ begin
502
+ end
503
+ begin
504
+ begin
505
+ top -= 1
506
+ cs = stack[top]
507
+ _goto_level = _again
508
+ next
509
+ end
510
+ end
511
+ when 17 then
512
+ begin
513
+ begin
514
+ stack[top] = cs
515
+ top+= 1
516
+ cs = 13
517
+ _goto_level = _again
518
+ next
519
+ end
520
+ end
521
+ begin
522
+ content_location.location = data[token_string_s..(p-1)] end
523
+ when 16 then
524
+ begin
525
+ qstr_s = p end
526
+ begin
527
+ content_location.location = data[token_string_s..(p-1)] end
528
+ begin
529
+ begin
530
+ stack[top] = cs
531
+ top+= 1
532
+ cs = 13
533
+ _goto_level = _again
534
+ next
535
+ end
536
+ end
537
+ end
538
+ end
539
+ end
540
+ if _goto_level <= _again
541
+ if cs == 0
542
+ _goto_level = _out
543
+ next
544
+ end
545
+ p += 1
546
+ if p != pe
547
+ _goto_level = _resume
548
+ next
549
+ end
550
+ end
551
+ if _goto_level <= _test_eof
552
+ if p == eof
553
+ case _eof_actions[cs]
554
+ when 11 then
555
+ begin
556
+ content_location.location = data[token_string_s..(p-1)] end
557
+ when 4 then
558
+ begin
559
+ end
560
+ end
561
+ end
28
562
 
29
- else
30
- raise Mail::Field::ParseError.new(Mail::ContentLocationElement, s, "Failed to process unknown action: #{action}")
31
- end
563
+ end
564
+ if _goto_level <= _out
565
+ break
566
+ end
567
+ end
568
+ end
569
+
570
+
571
+ if p != eof || cs < 18
572
+ raise Mail::Field::ParseError.new(Mail::ContentLocationElement, data, "Only able to parse up to #{data[0..p]}")
32
573
  end
574
+
33
575
  content_location
34
576
  end
35
577
  end