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.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +25 -6
- data/Dependencies.txt +0 -1
- data/Gemfile +5 -8
- data/MIT-LICENSE +1 -1
- data/README.md +22 -11
- data/Rakefile +0 -6
- data/lib/mail.rb +2 -10
- data/lib/mail/attachments_list.rb +3 -2
- data/lib/mail/body.rb +3 -3
- data/lib/mail/core_extensions/smtp.rb +19 -16
- data/lib/mail/core_extensions/string.rb +0 -4
- data/lib/mail/elements/address.rb +9 -4
- data/lib/mail/elements/address_list.rb +10 -18
- data/lib/mail/elements/content_disposition_element.rb +8 -15
- data/lib/mail/elements/content_location_element.rb +5 -10
- data/lib/mail/elements/content_transfer_encoding_element.rb +5 -10
- data/lib/mail/elements/content_type_element.rb +8 -19
- data/lib/mail/elements/date_time_element.rb +6 -14
- data/lib/mail/elements/envelope_from_element.rb +14 -21
- data/lib/mail/elements/message_ids_element.rb +8 -12
- data/lib/mail/elements/mime_version_element.rb +6 -14
- data/lib/mail/elements/phrase_list.rb +6 -9
- data/lib/mail/elements/received_element.rb +9 -15
- data/lib/mail/encodings.rb +12 -14
- data/lib/mail/field.rb +7 -4
- data/lib/mail/fields/common/parameter_hash.rb +1 -1
- data/lib/mail/fields/content_type_field.rb +2 -7
- data/lib/mail/fields/unstructured_field.rb +2 -2
- data/lib/mail/header.rb +1 -0
- data/lib/mail/message.rb +23 -25
- data/lib/mail/multibyte.rb +51 -0
- data/lib/mail/multibyte/chars.rb +27 -27
- data/lib/mail/network/delivery_methods/exim.rb +10 -6
- data/lib/mail/network/delivery_methods/sendmail.rb +2 -6
- data/lib/mail/network/delivery_methods/smtp.rb +14 -6
- data/lib/mail/parsers.rb +16 -24
- data/lib/mail/parsers/address_lists_parser.rb +15321 -112
- data/lib/mail/parsers/address_lists_parser.rl +166 -0
- data/lib/mail/parsers/content_disposition_parser.rb +698 -55
- data/lib/mail/parsers/content_disposition_parser.rl +76 -0
- data/lib/mail/parsers/content_location_parser.rb +565 -23
- data/lib/mail/parsers/content_location_parser.rl +65 -0
- data/lib/mail/parsers/content_transfer_encoding_parser.rb +410 -22
- data/lib/mail/parsers/content_transfer_encoding_parser.rl +58 -0
- data/lib/mail/parsers/content_type_parser.rb +841 -54
- data/lib/mail/parsers/content_type_parser.rl +77 -0
- data/lib/mail/parsers/date_time_parser.rb +773 -26
- data/lib/mail/parsers/date_time_parser.rl +56 -0
- data/lib/mail/parsers/envelope_from_parser.rb +2051 -36
- data/lib/mail/parsers/envelope_from_parser.rl +76 -0
- data/lib/mail/parsers/message_ids_parser.rb +1494 -25
- data/lib/mail/parsers/message_ids_parser.rl +76 -0
- data/lib/mail/parsers/mime_version_parser.rb +393 -26
- data/lib/mail/parsers/mime_version_parser.rl +55 -0
- data/lib/mail/parsers/phrase_lists_parser.rb +529 -19
- data/lib/mail/parsers/phrase_lists_parser.rl +77 -0
- data/lib/mail/parsers/received_parser.rb +4711 -38
- data/lib/mail/parsers/received_parser.rl +78 -0
- data/lib/mail/parsers/rfc2045_content_transfer_encoding.rl +12 -0
- data/lib/mail/parsers/rfc2045_content_type.rl +24 -0
- data/lib/mail/parsers/rfc2045_mime.rl +15 -0
- data/lib/mail/parsers/rfc2183_content_disposition.rl +14 -0
- data/lib/mail/parsers/rfc5234_abnf_core_rules.rl +16 -0
- data/lib/mail/parsers/rfc5322.rl +57 -0
- data/lib/mail/parsers/rfc5322_address.rl +70 -0
- data/lib/mail/parsers/{ragel/date_time.rl → rfc5322_date_time.rl} +7 -1
- data/lib/mail/parsers/rfc5322_lexical_tokens.rl +56 -0
- data/lib/mail/part.rb +1 -1
- data/lib/mail/parts_list.rb +5 -6
- data/lib/mail/utilities.rb +4 -2
- data/lib/mail/version.rb +3 -3
- data/lib/mail/version_specific/ruby_1_8.rb +28 -2
- data/lib/mail/version_specific/ruby_1_9.rb +48 -8
- metadata +28 -45
- data/lib/mail/core_extensions/string/access.rb +0 -146
- data/lib/mail/core_extensions/string/multibyte.rb +0 -79
- data/lib/mail/parsers/ragel.rb +0 -18
- data/lib/mail/parsers/ragel/common.rl +0 -185
- data/lib/mail/parsers/ragel/parser_info.rb +0 -61
- data/lib/mail/parsers/ragel/ruby.rb +0 -40
- data/lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb +0 -14864
- data/lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb +0 -751
- data/lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb +0 -614
- data/lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb +0 -447
- data/lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb +0 -825
- data/lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb +0 -817
- data/lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb +0 -2149
- data/lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb +0 -1570
- data/lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb +0 -440
- data/lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb +0 -564
- data/lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/machines/rb_actions.rl +0 -51
- data/lib/mail/parsers/ragel/ruby/machines/received_machine.rb +0 -5144
- data/lib/mail/parsers/ragel/ruby/machines/received_machine.rb.rl +0 -37
- data/lib/mail/parsers/ragel/ruby/parser.rb.rl.erb +0 -37
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'mail/utilities'
|
3
|
+
|
4
|
+
%%{
|
5
|
+
# RFC 2557 Content-Location
|
6
|
+
# https://tools.ietf.org/html/rfc2557#section-4.1
|
7
|
+
machine content_location;
|
8
|
+
|
9
|
+
# Quoted String
|
10
|
+
action qstr_s { qstr_s = p }
|
11
|
+
action qstr_e { content_location.location = data[qstr_s..(p-1)] }
|
12
|
+
|
13
|
+
# Token String
|
14
|
+
action token_string_s { token_string_s = p }
|
15
|
+
action token_string_e { content_location.location = data[token_string_s..(p-1)] }
|
16
|
+
|
17
|
+
# No-op actions
|
18
|
+
action comment_e { }
|
19
|
+
action comment_s { }
|
20
|
+
action phrase_e { }
|
21
|
+
action phrase_s { }
|
22
|
+
action main_type_e { }
|
23
|
+
action main_type_s { }
|
24
|
+
action sub_type_e { }
|
25
|
+
action sub_type_s { }
|
26
|
+
action param_attr_e { }
|
27
|
+
action param_attr_s { }
|
28
|
+
action param_val_e { }
|
29
|
+
action param_val_s { }
|
30
|
+
|
31
|
+
include rfc2045_content_type "rfc2045_content_type.rl";
|
32
|
+
|
33
|
+
location = quoted_string | ((token | 0x3d)+ >token_string_s %token_string_e);
|
34
|
+
main := CFWS? location CFWS?;
|
35
|
+
}%%
|
36
|
+
|
37
|
+
module Mail::Parsers
|
38
|
+
module ContentLocationParser
|
39
|
+
ContentLocationStruct = Struct.new(:location, :error)
|
40
|
+
|
41
|
+
%%write data noprefix;
|
42
|
+
|
43
|
+
def self.parse(data)
|
44
|
+
content_location = ContentLocationStruct.new(nil)
|
45
|
+
return content_location if Mail::Utilities.blank?(data)
|
46
|
+
|
47
|
+
# Parser state
|
48
|
+
disp_type_s = param_attr_s = param_attr = qstr_s = qstr = param_val_s = nil
|
49
|
+
|
50
|
+
# 5.1 Variables Used by Ragel
|
51
|
+
p = 0
|
52
|
+
eof = pe = data.length
|
53
|
+
stack = []
|
54
|
+
|
55
|
+
%%write init;
|
56
|
+
%%write exec;
|
57
|
+
|
58
|
+
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]}")
|
60
|
+
end
|
61
|
+
|
62
|
+
content_location
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -1,31 +1,419 @@
|
|
1
|
+
|
1
2
|
# frozen_string_literal: true
|
3
|
+
require 'mail/utilities'
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
|
2
8
|
module Mail::Parsers
|
3
|
-
|
9
|
+
module ContentTransferEncodingParser
|
10
|
+
ContentTransferEncodingStruct = Struct.new(:encoding, :error)
|
4
11
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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, 10, 10, 9, 32,
|
21
|
+
9, 126, 1, 127, 1, 127,
|
22
|
+
10, 10, 9, 32, 0,
|
23
|
+
127, 9, 126, 9, 59,
|
24
|
+
9, 59, 9, 40, 9, 40,
|
25
|
+
0, 0, 0
|
26
|
+
]
|
10
27
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
28
|
+
class << self
|
29
|
+
attr_accessor :_key_spans
|
30
|
+
private :_key_spans, :_key_spans=
|
31
|
+
end
|
32
|
+
self._key_spans = [
|
33
|
+
0, 118, 1, 24, 1, 24, 1, 24,
|
34
|
+
118, 127, 127, 1, 24, 128, 118, 51,
|
35
|
+
51, 32, 32, 0
|
36
|
+
]
|
37
|
+
|
38
|
+
class << self
|
39
|
+
attr_accessor :_index_offsets
|
40
|
+
private :_index_offsets, :_index_offsets=
|
41
|
+
end
|
42
|
+
self._index_offsets = [
|
43
|
+
0, 0, 119, 121, 146, 148, 173, 175,
|
44
|
+
200, 319, 447, 575, 577, 602, 731, 850,
|
45
|
+
902, 954, 987, 1020
|
46
|
+
]
|
47
|
+
|
48
|
+
class << self
|
49
|
+
attr_accessor :_indicies
|
50
|
+
private :_indicies, :_indicies=
|
51
|
+
end
|
52
|
+
self._indicies = [
|
53
|
+
0, 1, 1, 1, 2, 1, 1, 1,
|
54
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
55
|
+
1, 1, 1, 1, 1, 1, 1, 0,
|
56
|
+
3, 3, 3, 3, 3, 3, 3, 4,
|
57
|
+
1, 3, 3, 3, 3, 3, 1, 3,
|
58
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
59
|
+
3, 1, 1, 1, 1, 1, 1, 1,
|
60
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
61
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
62
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
63
|
+
3, 3, 1, 1, 1, 3, 3, 3,
|
64
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
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, 1, 5,
|
68
|
+
1, 0, 1, 1, 1, 1, 1, 1,
|
69
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
70
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
71
|
+
0, 1, 6, 1, 7, 1, 1, 1,
|
72
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
73
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
74
|
+
1, 1, 1, 7, 1, 8, 1, 9,
|
75
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
76
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
77
|
+
1, 1, 1, 1, 1, 1, 9, 1,
|
78
|
+
10, 1, 1, 1, 11, 1, 1, 1,
|
79
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
80
|
+
1, 1, 1, 1, 1, 1, 1, 10,
|
81
|
+
12, 12, 12, 12, 12, 12, 12, 13,
|
82
|
+
1, 12, 12, 12, 12, 12, 1, 12,
|
83
|
+
12, 12, 12, 12, 12, 12, 12, 12,
|
84
|
+
12, 1, 1, 1, 1, 1, 1, 1,
|
85
|
+
12, 12, 12, 12, 12, 12, 12, 12,
|
86
|
+
12, 12, 12, 12, 12, 12, 12, 12,
|
87
|
+
12, 12, 12, 12, 12, 12, 12, 12,
|
88
|
+
12, 12, 1, 1, 1, 12, 12, 12,
|
89
|
+
12, 12, 12, 12, 12, 12, 12, 12,
|
90
|
+
12, 12, 12, 12, 12, 12, 12, 12,
|
91
|
+
12, 12, 12, 12, 12, 12, 12, 12,
|
92
|
+
12, 12, 12, 12, 12, 12, 1, 14,
|
93
|
+
14, 14, 14, 14, 14, 14, 14, 14,
|
94
|
+
1, 14, 14, 15, 14, 14, 14, 14,
|
95
|
+
14, 14, 14, 14, 14, 14, 14, 14,
|
96
|
+
14, 14, 14, 14, 14, 14, 14, 14,
|
97
|
+
14, 14, 14, 14, 14, 14, 16, 17,
|
98
|
+
14, 14, 14, 14, 14, 14, 14, 14,
|
99
|
+
14, 14, 14, 14, 14, 14, 14, 14,
|
100
|
+
14, 14, 14, 14, 14, 14, 14, 14,
|
101
|
+
14, 14, 14, 14, 14, 14, 14, 14,
|
102
|
+
14, 14, 14, 14, 14, 14, 14, 14,
|
103
|
+
14, 14, 14, 14, 14, 14, 14, 14,
|
104
|
+
14, 14, 18, 14, 14, 14, 14, 14,
|
105
|
+
14, 14, 14, 14, 14, 14, 14, 14,
|
106
|
+
14, 14, 14, 14, 14, 14, 14, 14,
|
107
|
+
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,
|
126
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
127
|
+
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
|
+
19, 19, 19, 19, 19, 19, 19, 19,
|
142
|
+
19, 19, 19, 19, 19, 19, 19, 19,
|
143
|
+
19, 19, 19, 19, 19, 19, 19, 19,
|
144
|
+
19, 19, 1, 25, 1, 1, 1, 26,
|
145
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
146
|
+
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,
|
160
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
161
|
+
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,
|
164
|
+
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
|
+
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
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
171
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
172
|
+
35, 1, 9, 1, 1, 1, 36, 1,
|
173
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
174
|
+
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
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
178
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
179
|
+
1, 1, 35, 1, 1, 1, 1, 1,
|
180
|
+
1, 1, 39, 1, 1, 0
|
181
|
+
]
|
182
|
+
|
183
|
+
class << self
|
184
|
+
attr_accessor :_trans_targs
|
185
|
+
private :_trans_targs, :_trans_targs=
|
186
|
+
end
|
187
|
+
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
|
193
|
+
]
|
194
|
+
|
195
|
+
class << self
|
196
|
+
attr_accessor :_trans_actions
|
197
|
+
private :_trans_actions, :_trans_actions=
|
198
|
+
end
|
199
|
+
self._trans_actions = [
|
200
|
+
0, 0, 0, 1, 2, 0, 0, 0,
|
201
|
+
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
|
205
|
+
]
|
206
|
+
|
207
|
+
class << self
|
208
|
+
attr_accessor :_eof_actions
|
209
|
+
private :_eof_actions, :_eof_actions=
|
210
|
+
end
|
211
|
+
self._eof_actions = [
|
212
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
213
|
+
0, 0, 0, 0, 0, 0, 10, 0,
|
214
|
+
3, 0, 3, 0
|
215
|
+
]
|
15
216
|
|
217
|
+
class << self
|
218
|
+
attr_accessor :start
|
219
|
+
end
|
220
|
+
self.start = 1;
|
221
|
+
class << self
|
222
|
+
attr_accessor :first_final
|
223
|
+
end
|
224
|
+
self.first_final = 14;
|
225
|
+
class << self
|
226
|
+
attr_accessor :error
|
227
|
+
end
|
228
|
+
self.error = 0;
|
229
|
+
|
230
|
+
class << self
|
231
|
+
attr_accessor :en_comment_tail
|
232
|
+
end
|
233
|
+
self.en_comment_tail = 9;
|
234
|
+
class << self
|
235
|
+
attr_accessor :en_main
|
236
|
+
end
|
237
|
+
self.en_main = 1;
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
def self.parse(data)
|
242
|
+
content_transfer_encoding = ContentTransferEncodingStruct.new('')
|
243
|
+
return content_transfer_encoding if Mail::Utilities.blank?(data)
|
244
|
+
|
245
|
+
# Parser state
|
16
246
|
encoding_s = nil
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
247
|
+
|
248
|
+
# 5.1 Variables Used by Ragel
|
249
|
+
p = 0
|
250
|
+
eof = pe = data.length
|
251
|
+
stack = []
|
252
|
+
|
253
|
+
|
254
|
+
begin
|
255
|
+
p ||= 0
|
256
|
+
pe ||= data.length
|
257
|
+
cs = start
|
258
|
+
top = 0
|
259
|
+
end
|
260
|
+
|
261
|
+
|
262
|
+
begin
|
263
|
+
testEof = false
|
264
|
+
_slen, _trans, _keys, _inds, _acts, _nacts = nil
|
265
|
+
_goto_level = 0
|
266
|
+
_resume = 10
|
267
|
+
_eof_trans = 15
|
268
|
+
_again = 20
|
269
|
+
_test_eof = 30
|
270
|
+
_out = 40
|
271
|
+
while true
|
272
|
+
if _goto_level <= 0
|
273
|
+
if p == pe
|
274
|
+
_goto_level = _test_eof
|
275
|
+
next
|
276
|
+
end
|
277
|
+
if cs == 0
|
278
|
+
_goto_level = _out
|
279
|
+
next
|
280
|
+
end
|
281
|
+
end
|
282
|
+
if _goto_level <= _resume
|
283
|
+
_keys = cs << 1
|
284
|
+
_inds = _index_offsets[cs]
|
285
|
+
_slen = _key_spans[cs]
|
286
|
+
_wide = data[p].ord
|
287
|
+
_trans = if ( _slen > 0 &&
|
288
|
+
_trans_keys[_keys] <= _wide &&
|
289
|
+
_wide <= _trans_keys[_keys + 1]
|
290
|
+
) then
|
291
|
+
_indicies[ _inds + _wide - _trans_keys[_keys] ]
|
292
|
+
else
|
293
|
+
_indicies[ _inds + _slen ]
|
294
|
+
end
|
295
|
+
cs = _trans_targs[_trans]
|
296
|
+
if _trans_actions[_trans] != 0
|
297
|
+
case _trans_actions[_trans]
|
298
|
+
when 1 then
|
299
|
+
begin
|
300
|
+
encoding_s = p end
|
301
|
+
when 10 then
|
302
|
+
begin
|
303
|
+
content_transfer_encoding.encoding = data[encoding_s..(p-1)].downcase end
|
304
|
+
when 3 then
|
305
|
+
begin
|
306
|
+
end
|
307
|
+
when 6 then
|
308
|
+
begin
|
309
|
+
end
|
310
|
+
when 2 then
|
311
|
+
begin
|
312
|
+
begin
|
313
|
+
stack[top] = cs
|
314
|
+
top+= 1
|
315
|
+
cs = 9
|
316
|
+
_goto_level = _again
|
317
|
+
next
|
318
|
+
end
|
319
|
+
end
|
320
|
+
when 9 then
|
321
|
+
begin
|
322
|
+
begin
|
323
|
+
top -= 1
|
324
|
+
cs = stack[top]
|
325
|
+
_goto_level = _again
|
326
|
+
next
|
327
|
+
end
|
328
|
+
end
|
329
|
+
when 11 then
|
330
|
+
begin
|
331
|
+
content_transfer_encoding.encoding = data[encoding_s..(p-1)].downcase end
|
332
|
+
begin
|
333
|
+
begin
|
334
|
+
stack[top] = cs
|
335
|
+
top+= 1
|
336
|
+
cs = 9
|
337
|
+
_goto_level = _again
|
338
|
+
next
|
339
|
+
end
|
340
|
+
end
|
341
|
+
when 4 then
|
342
|
+
begin
|
343
|
+
end
|
344
|
+
begin
|
345
|
+
encoding_s = p end
|
346
|
+
when 5 then
|
347
|
+
begin
|
348
|
+
end
|
349
|
+
begin
|
350
|
+
begin
|
351
|
+
stack[top] = cs
|
352
|
+
top+= 1
|
353
|
+
cs = 9
|
354
|
+
_goto_level = _again
|
355
|
+
next
|
356
|
+
end
|
357
|
+
end
|
358
|
+
when 7 then
|
359
|
+
begin
|
360
|
+
end
|
361
|
+
begin
|
362
|
+
begin
|
363
|
+
stack[top] = cs
|
364
|
+
top+= 1
|
365
|
+
cs = 9
|
366
|
+
_goto_level = _again
|
367
|
+
next
|
368
|
+
end
|
369
|
+
end
|
370
|
+
when 8 then
|
371
|
+
begin
|
372
|
+
end
|
373
|
+
begin
|
374
|
+
begin
|
375
|
+
top -= 1
|
376
|
+
cs = stack[top]
|
377
|
+
_goto_level = _again
|
378
|
+
next
|
379
|
+
end
|
380
|
+
end
|
381
|
+
end
|
382
|
+
end
|
383
|
+
end
|
384
|
+
if _goto_level <= _again
|
385
|
+
if cs == 0
|
386
|
+
_goto_level = _out
|
387
|
+
next
|
388
|
+
end
|
389
|
+
p += 1
|
390
|
+
if p != pe
|
391
|
+
_goto_level = _resume
|
392
|
+
next
|
393
|
+
end
|
394
|
+
end
|
395
|
+
if _goto_level <= _test_eof
|
396
|
+
if p == eof
|
397
|
+
case _eof_actions[cs]
|
398
|
+
when 10 then
|
399
|
+
begin
|
400
|
+
content_transfer_encoding.encoding = data[encoding_s..(p-1)].downcase end
|
401
|
+
when 3 then
|
402
|
+
begin
|
403
|
+
end
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
end
|
408
|
+
if _goto_level <= _out
|
409
|
+
break
|
410
|
+
end
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
|
415
|
+
if p != eof || cs < 14
|
416
|
+
raise Mail::Field::ParseError.new(Mail::ContentTransferEncodingElement, data, "Only able to parse up to #{data[0..p]}")
|
29
417
|
end
|
30
418
|
|
31
419
|
content_transfer_encoding
|