mail 2.6.1 → 2.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/MIT-LICENSE +1 -1
- data/README.md +92 -80
- data/lib/mail/attachments_list.rb +11 -5
- data/lib/mail/body.rb +81 -44
- data/lib/mail/check_delivery_params.rb +50 -10
- data/lib/mail/configuration.rb +3 -0
- data/lib/mail/{patterns.rb → constants.rb} +26 -6
- data/lib/mail/core_extensions/smtp.rb +20 -16
- data/lib/mail/core_extensions/string.rb +1 -27
- data/lib/mail/elements/address.rb +81 -93
- data/lib/mail/elements/address_list.rb +12 -29
- data/lib/mail/elements/content_disposition_element.rb +9 -15
- data/lib/mail/elements/content_location_element.rb +8 -12
- data/lib/mail/elements/content_transfer_encoding_element.rb +6 -10
- data/lib/mail/elements/content_type_element.rb +9 -19
- data/lib/mail/elements/date_time_element.rb +7 -14
- data/lib/mail/elements/envelope_from_element.rb +15 -21
- data/lib/mail/elements/message_ids_element.rb +12 -14
- data/lib/mail/elements/mime_version_element.rb +7 -14
- data/lib/mail/elements/phrase_list.rb +7 -9
- data/lib/mail/elements/received_element.rb +10 -15
- data/lib/mail/elements.rb +1 -0
- data/lib/mail/encodings/7bit.rb +6 -15
- data/lib/mail/encodings/8bit.rb +5 -18
- data/lib/mail/encodings/base64.rb +15 -10
- data/lib/mail/encodings/binary.rb +4 -22
- data/lib/mail/encodings/identity.rb +24 -0
- data/lib/mail/encodings/quoted_printable.rb +13 -7
- data/lib/mail/encodings/transfer_encoding.rb +47 -28
- data/lib/mail/encodings/unix_to_unix.rb +20 -0
- data/lib/mail/encodings.rb +121 -82
- data/lib/mail/envelope.rb +2 -1
- data/lib/mail/field.rb +114 -62
- data/lib/mail/field_list.rb +2 -1
- data/lib/mail/fields/bcc_field.rb +17 -5
- data/lib/mail/fields/cc_field.rb +2 -2
- data/lib/mail/fields/comments_field.rb +2 -1
- data/lib/mail/fields/common/address_container.rb +3 -2
- data/lib/mail/fields/common/common_address.rb +40 -14
- data/lib/mail/fields/common/common_date.rb +2 -1
- data/lib/mail/fields/common/common_field.rb +6 -11
- data/lib/mail/fields/common/common_message_id.rb +3 -2
- data/lib/mail/fields/common/parameter_hash.rb +5 -4
- data/lib/mail/fields/content_description_field.rb +2 -1
- data/lib/mail/fields/content_disposition_field.rb +14 -13
- data/lib/mail/fields/content_id_field.rb +5 -4
- data/lib/mail/fields/content_location_field.rb +3 -2
- data/lib/mail/fields/content_transfer_encoding_field.rb +3 -2
- data/lib/mail/fields/content_type_field.rb +7 -11
- data/lib/mail/fields/date_field.rb +4 -4
- data/lib/mail/fields/from_field.rb +2 -2
- data/lib/mail/fields/in_reply_to_field.rb +2 -1
- data/lib/mail/fields/keywords_field.rb +3 -3
- data/lib/mail/fields/message_id_field.rb +3 -2
- data/lib/mail/fields/mime_version_field.rb +4 -3
- data/lib/mail/fields/optional_field.rb +5 -1
- data/lib/mail/fields/received_field.rb +5 -4
- data/lib/mail/fields/references_field.rb +2 -1
- data/lib/mail/fields/reply_to_field.rb +2 -2
- data/lib/mail/fields/resent_bcc_field.rb +2 -2
- data/lib/mail/fields/resent_cc_field.rb +2 -2
- data/lib/mail/fields/resent_date_field.rb +2 -2
- data/lib/mail/fields/resent_from_field.rb +2 -2
- data/lib/mail/fields/resent_message_id_field.rb +2 -1
- data/lib/mail/fields/resent_sender_field.rb +2 -2
- data/lib/mail/fields/resent_to_field.rb +2 -2
- data/lib/mail/fields/return_path_field.rb +2 -2
- data/lib/mail/fields/sender_field.rb +2 -2
- data/lib/mail/fields/structured_field.rb +1 -0
- data/lib/mail/fields/subject_field.rb +2 -1
- data/lib/mail/fields/to_field.rb +2 -2
- data/lib/mail/fields/unstructured_field.rb +28 -10
- data/lib/mail/fields.rb +1 -0
- data/lib/mail/header.rb +18 -14
- data/lib/mail/indifferent_hash.rb +1 -0
- data/lib/mail/mail.rb +6 -11
- data/lib/mail/matchers/attachment_matchers.rb +29 -0
- data/lib/mail/matchers/has_sent_mail.rb +53 -9
- data/lib/mail/message.rb +99 -89
- data/lib/mail/multibyte/chars.rb +32 -30
- data/lib/mail/multibyte/unicode.rb +31 -26
- data/lib/mail/multibyte/utils.rb +1 -0
- data/lib/mail/multibyte.rb +65 -15
- data/lib/mail/network/delivery_methods/exim.rb +7 -10
- data/lib/mail/network/delivery_methods/file_delivery.rb +5 -8
- data/lib/mail/network/delivery_methods/logger_delivery.rb +37 -0
- data/lib/mail/network/delivery_methods/sendmail.rb +17 -11
- data/lib/mail/network/delivery_methods/smtp.rb +60 -53
- data/lib/mail/network/delivery_methods/smtp_connection.rb +11 -6
- data/lib/mail/network/delivery_methods/test_mailer.rb +6 -8
- data/lib/mail/network/retriever_methods/base.rb +1 -0
- data/lib/mail/network/retriever_methods/imap.rb +19 -5
- data/lib/mail/network/retriever_methods/pop3.rb +4 -1
- data/lib/mail/network/retriever_methods/test_retriever.rb +2 -1
- data/lib/mail/network.rb +2 -0
- data/lib/mail/parser_tools.rb +15 -0
- data/lib/mail/parsers/address_lists_parser.rb +33208 -104
- data/lib/mail/parsers/address_lists_parser.rl +172 -0
- data/lib/mail/parsers/content_disposition_parser.rb +877 -49
- data/lib/mail/parsers/content_disposition_parser.rl +82 -0
- data/lib/mail/parsers/content_location_parser.rb +804 -23
- data/lib/mail/parsers/content_location_parser.rl +71 -0
- data/lib/mail/parsers/content_transfer_encoding_parser.rb +502 -19
- data/lib/mail/parsers/content_transfer_encoding_parser.rl +64 -0
- data/lib/mail/parsers/content_type_parser.rb +1024 -46
- data/lib/mail/parsers/content_type_parser.rl +83 -0
- data/lib/mail/parsers/date_time_parser.rb +872 -23
- data/lib/mail/parsers/date_time_parser.rl +62 -0
- data/lib/mail/parsers/envelope_from_parser.rb +3570 -34
- data/lib/mail/parsers/envelope_from_parser.rl +82 -0
- data/lib/mail/parsers/message_ids_parser.rb +2840 -25
- data/lib/mail/parsers/message_ids_parser.rl +82 -0
- data/lib/mail/parsers/mime_version_parser.rb +492 -26
- data/lib/mail/parsers/mime_version_parser.rl +61 -0
- data/lib/mail/parsers/phrase_lists_parser.rb +862 -17
- data/lib/mail/parsers/phrase_lists_parser.rl +83 -0
- data/lib/mail/parsers/received_parser.rb +8765 -36
- data/lib/mail/parsers/received_parser.rl +84 -0
- data/lib/mail/parsers/rfc2045_content_transfer_encoding.rl +13 -0
- data/lib/mail/parsers/rfc2045_content_type.rl +25 -0
- data/lib/mail/parsers/rfc2045_mime.rl +16 -0
- data/lib/mail/parsers/rfc2183_content_disposition.rl +15 -0
- data/lib/mail/parsers/rfc3629_utf8.rl +19 -0
- data/lib/mail/parsers/rfc5234_abnf_core_rules.rl +22 -0
- data/lib/mail/parsers/rfc5322.rl +59 -0
- data/lib/mail/parsers/rfc5322_address.rl +72 -0
- data/lib/mail/parsers/{ragel/date_time.rl → rfc5322_date_time.rl} +8 -1
- data/lib/mail/parsers/rfc5322_lexical_tokens.rl +60 -0
- data/lib/mail/parsers.rb +17 -24
- data/lib/mail/part.rb +8 -5
- data/lib/mail/parts_list.rb +31 -14
- data/lib/mail/utilities.rb +112 -13
- 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 +52 -8
- data/lib/mail/version_specific/ruby_1_9.rb +143 -24
- data/lib/mail.rb +8 -14
- metadata +71 -81
- data/CHANGELOG.rdoc +0 -752
- data/CONTRIBUTING.md +0 -60
- data/Dependencies.txt +0 -2
- data/Gemfile +0 -15
- data/Rakefile +0 -29
- data/TODO.rdoc +0 -9
- data/VERSION +0 -4
- data/lib/mail/core_extensions/nil.rb +0 -19
- data/lib/mail/core_extensions/object.rb +0 -13
- data/lib/mail/core_extensions/string/access.rb +0 -145
- data/lib/mail/core_extensions/string/multibyte.rb +0 -78
- data/lib/mail/multibyte/exceptions.rb +0 -8
- data/lib/mail/parsers/ragel/common.rl +0 -184
- data/lib/mail/parsers/ragel/parser_info.rb +0 -61
- 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 -2129
- 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
- data/lib/mail/parsers/ragel/ruby.rb +0 -39
- data/lib/mail/parsers/ragel.rb +0 -17
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'mail/utilities'
|
3
|
+
require 'mail/parser_tools'
|
4
|
+
|
5
|
+
%%{
|
6
|
+
# RFC 2557 Content-Location
|
7
|
+
# https://tools.ietf.org/html/rfc2557#section-4.1
|
8
|
+
machine content_location;
|
9
|
+
alphtype int;
|
10
|
+
|
11
|
+
# Quoted String
|
12
|
+
action qstr_s { qstr_s = p }
|
13
|
+
action qstr_e { content_location.location = chars(data, qstr_s, p-1) }
|
14
|
+
|
15
|
+
# Token String
|
16
|
+
action token_string_s { token_string_s = p }
|
17
|
+
action token_string_e { content_location.location = chars(data, token_string_s, p-1) }
|
18
|
+
|
19
|
+
# No-op actions
|
20
|
+
action comment_e { }
|
21
|
+
action comment_s { }
|
22
|
+
action phrase_e { }
|
23
|
+
action phrase_s { }
|
24
|
+
action main_type_e { }
|
25
|
+
action main_type_s { }
|
26
|
+
action sub_type_e { }
|
27
|
+
action sub_type_s { }
|
28
|
+
action param_attr_e { }
|
29
|
+
action param_attr_s { }
|
30
|
+
action param_val_e { }
|
31
|
+
action param_val_s { }
|
32
|
+
|
33
|
+
include rfc2045_content_type "rfc2045_content_type.rl";
|
34
|
+
|
35
|
+
location = quoted_string | ((token | 0x3d)+ >token_string_s %token_string_e);
|
36
|
+
main := CFWS? location CFWS?;
|
37
|
+
}%%
|
38
|
+
|
39
|
+
module Mail::Parsers
|
40
|
+
module ContentLocationParser
|
41
|
+
extend Mail::ParserTools
|
42
|
+
|
43
|
+
ContentLocationStruct = Struct.new(:location, :error)
|
44
|
+
|
45
|
+
%%write data noprefix;
|
46
|
+
|
47
|
+
def self.parse(data)
|
48
|
+
data = data.dup.force_encoding(Encoding::ASCII_8BIT) if data.respond_to?(:force_encoding)
|
49
|
+
|
50
|
+
content_location = ContentLocationStruct.new(nil)
|
51
|
+
return content_location if Mail::Utilities.blank?(data)
|
52
|
+
|
53
|
+
# Parser state
|
54
|
+
disp_type_s = param_attr_s = param_attr = qstr_s = qstr = param_val_s = nil
|
55
|
+
|
56
|
+
# 5.1 Variables Used by Ragel
|
57
|
+
p = 0
|
58
|
+
eof = pe = data.length
|
59
|
+
stack = []
|
60
|
+
|
61
|
+
%%write init;
|
62
|
+
%%write exec;
|
63
|
+
|
64
|
+
if p != eof || cs < %%{ write first_final; }%%
|
65
|
+
raise Mail::Field::IncompleteParseError.new(Mail::ContentLocationElement, data, p)
|
66
|
+
end
|
67
|
+
|
68
|
+
content_location
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -1,32 +1,515 @@
|
|
1
|
+
|
2
|
+
# frozen_string_literal: true
|
3
|
+
require "mail/utilities"
|
4
|
+
require "mail/parser_tools"
|
5
|
+
|
1
6
|
module Mail::Parsers
|
2
|
-
|
7
|
+
module ContentTransferEncodingParser
|
8
|
+
extend Mail::ParserTools
|
3
9
|
|
4
|
-
|
5
|
-
content_transfer_encoding = ContentTransferEncodingStruct.new("")
|
6
|
-
if s.blank?
|
7
|
-
return content_transfer_encoding
|
8
|
-
end
|
10
|
+
ContentTransferEncodingStruct = Struct.new(:encoding, :error)
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
class << self
|
13
|
+
attr_accessor :_trans_keys
|
14
|
+
private :_trans_keys, :_trans_keys=
|
15
|
+
end
|
16
|
+
self._trans_keys = [
|
17
|
+
0, 0, 9, 126, 10, 10,
|
18
|
+
9, 32, 10, 10, 9,
|
19
|
+
32, 10, 10, 9, 32,
|
20
|
+
9, 126, 1, 244, 1, 244,
|
21
|
+
10, 10, 9, 32, 0,
|
22
|
+
244, 128, 191, 160, 191,
|
23
|
+
128, 191, 128, 159, 144, 191,
|
24
|
+
128, 191, 128, 143, 9,
|
25
|
+
126, 9, 59, 9, 59,
|
26
|
+
9, 40, 9, 40, 0, 0,
|
27
|
+
0,
|
28
|
+
]
|
29
|
+
|
30
|
+
class << self
|
31
|
+
attr_accessor :_key_spans
|
32
|
+
private :_key_spans, :_key_spans=
|
33
|
+
end
|
34
|
+
self._key_spans = [
|
35
|
+
0, 118, 1, 24, 1, 24, 1, 24,
|
36
|
+
118, 244, 244, 1, 24, 245, 64, 32,
|
37
|
+
64, 32, 48, 64, 16, 118, 51, 51,
|
38
|
+
32, 32, 0,
|
39
|
+
]
|
40
|
+
|
41
|
+
class << self
|
42
|
+
attr_accessor :_index_offsets
|
43
|
+
private :_index_offsets, :_index_offsets=
|
44
|
+
end
|
45
|
+
self._index_offsets = [
|
46
|
+
0, 0, 119, 121, 146, 148, 173, 175,
|
47
|
+
200, 319, 564, 809, 811, 836, 1082, 1147,
|
48
|
+
1180, 1245, 1278, 1327, 1392, 1409, 1528, 1580,
|
49
|
+
1632, 1665, 1698,
|
50
|
+
]
|
51
|
+
|
52
|
+
class << self
|
53
|
+
attr_accessor :_indicies
|
54
|
+
private :_indicies, :_indicies=
|
55
|
+
end
|
56
|
+
self._indicies = [
|
57
|
+
0, 1, 1, 1, 2, 1, 1, 1,
|
58
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
59
|
+
1, 1, 1, 1, 1, 1, 1, 0,
|
60
|
+
3, 3, 3, 3, 3, 3, 3, 4,
|
61
|
+
1, 3, 3, 3, 3, 3, 1, 3,
|
62
|
+
3, 3, 3, 3, 3, 3, 3, 3,
|
63
|
+
3, 1, 1, 1, 1, 1, 1, 1,
|
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, 1, 1, 1, 3, 3, 3,
|
68
|
+
3, 3, 3, 3, 3, 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, 1, 5,
|
72
|
+
1, 0, 1, 1, 1, 1, 1, 1,
|
73
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
74
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
75
|
+
0, 1, 6, 1, 7, 1, 1, 1,
|
76
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
77
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
78
|
+
1, 1, 1, 7, 1, 8, 1, 9,
|
79
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
80
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
81
|
+
1, 1, 1, 1, 1, 1, 9, 1,
|
82
|
+
10, 1, 1, 1, 11, 1, 1, 1,
|
83
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
84
|
+
1, 1, 1, 1, 1, 1, 1, 10,
|
85
|
+
12, 12, 12, 12, 12, 12, 12, 13,
|
86
|
+
1, 12, 12, 12, 12, 12, 1, 12,
|
87
|
+
12, 12, 12, 12, 12, 12, 12, 12,
|
88
|
+
12, 1, 1, 1, 1, 1, 1, 1,
|
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, 1, 1, 1, 12, 12, 12,
|
93
|
+
12, 12, 12, 12, 12, 12, 12, 12,
|
94
|
+
12, 12, 12, 12, 12, 12, 12, 12,
|
95
|
+
12, 12, 12, 12, 12, 12, 12, 12,
|
96
|
+
12, 12, 12, 12, 12, 12, 1, 14,
|
97
|
+
14, 14, 14, 14, 14, 14, 14, 14,
|
98
|
+
1, 14, 14, 15, 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, 16, 17,
|
102
|
+
14, 14, 14, 14, 14, 14, 14, 14,
|
103
|
+
14, 14, 14, 14, 14, 14, 14, 14,
|
104
|
+
14, 14, 14, 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, 18, 14, 14, 14, 14, 14,
|
109
|
+
14, 14, 14, 14, 14, 14, 14, 14,
|
110
|
+
14, 14, 14, 14, 14, 14, 14, 14,
|
111
|
+
14, 14, 14, 14, 14, 14, 14, 14,
|
112
|
+
14, 14, 14, 14, 14, 14, 1, 1,
|
113
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
114
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
115
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
116
|
+
1, 1, 1, 1, 1, 1, 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
|
+
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, 20, 21,
|
125
|
+
21, 21, 21, 21, 21, 21, 21, 21,
|
126
|
+
21, 21, 21, 22, 21, 21, 23, 24,
|
127
|
+
24, 24, 25, 1, 26, 26, 26, 26,
|
128
|
+
26, 26, 26, 26, 26, 1, 26, 26,
|
129
|
+
27, 26, 26, 26, 26, 26, 26, 26,
|
130
|
+
26, 26, 26, 26, 26, 26, 26, 26,
|
131
|
+
26, 26, 26, 26, 26, 26, 26, 26,
|
132
|
+
26, 26, 26, 28, 29, 26, 26, 26,
|
133
|
+
26, 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, 26, 26, 26, 26, 26,
|
137
|
+
26, 26, 26, 26, 26, 26, 26, 26,
|
138
|
+
26, 26, 26, 26, 26, 26, 26, 30,
|
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, 26,
|
143
|
+
26, 26, 26, 1, 1, 1, 1, 1,
|
144
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
145
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
146
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
147
|
+
1, 1, 1, 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, 31, 31, 31,
|
152
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
153
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
154
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
155
|
+
31, 31, 31, 32, 33, 33, 33, 33,
|
156
|
+
33, 33, 33, 33, 33, 33, 33, 33,
|
157
|
+
34, 33, 33, 35, 36, 36, 36, 37,
|
158
|
+
1, 38, 1, 26, 1, 1, 1, 1,
|
159
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
160
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
161
|
+
1, 1, 26, 1, 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, 26, 26, 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, 1, 1, 1, 1,
|
178
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
179
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
180
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
181
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
182
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
183
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
184
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
185
|
+
1, 1, 1, 1, 1, 1, 31, 31,
|
186
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
187
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
188
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
189
|
+
31, 31, 31, 31, 32, 33, 33, 33,
|
190
|
+
33, 33, 33, 33, 33, 33, 33, 33,
|
191
|
+
33, 34, 33, 33, 35, 36, 36, 36,
|
192
|
+
37, 1, 26, 26, 26, 26, 26, 26,
|
193
|
+
26, 26, 26, 26, 26, 26, 26, 26,
|
194
|
+
26, 26, 26, 26, 26, 26, 26, 26,
|
195
|
+
26, 26, 26, 26, 26, 26, 26, 26,
|
196
|
+
26, 26, 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, 1, 31, 31, 31, 31, 31,
|
201
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
202
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
203
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
204
|
+
31, 31, 31, 1, 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, 31, 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, 1, 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, 31, 1, 33, 33,
|
217
|
+
33, 33, 33, 33, 33, 33, 33, 33,
|
218
|
+
33, 33, 33, 33, 33, 33, 33, 33,
|
219
|
+
33, 33, 33, 33, 33, 33, 33, 33,
|
220
|
+
33, 33, 33, 33, 33, 33, 33, 33,
|
221
|
+
33, 33, 33, 33, 33, 33, 33, 33,
|
222
|
+
33, 33, 33, 33, 33, 33, 1, 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, 33, 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, 1,
|
231
|
+
33, 33, 33, 33, 33, 33, 33, 33,
|
232
|
+
33, 33, 33, 33, 33, 33, 33, 33,
|
233
|
+
1, 39, 1, 1, 1, 40, 1, 1,
|
234
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
235
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
236
|
+
39, 41, 41, 41, 41, 41, 41, 41,
|
237
|
+
42, 1, 41, 41, 41, 41, 41, 1,
|
238
|
+
41, 41, 41, 41, 41, 41, 41, 41,
|
239
|
+
41, 41, 1, 43, 1, 1, 1, 1,
|
240
|
+
1, 41, 41, 41, 41, 41, 41, 41,
|
241
|
+
41, 41, 41, 41, 41, 41, 41, 41,
|
242
|
+
41, 41, 41, 41, 41, 41, 41, 41,
|
243
|
+
41, 41, 41, 1, 1, 1, 41, 41,
|
244
|
+
41, 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, 41, 41, 41, 41, 1,
|
248
|
+
7, 1, 1, 1, 44, 1, 1, 1,
|
249
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
250
|
+
1, 1, 1, 1, 1, 1, 1, 7,
|
251
|
+
1, 1, 1, 1, 1, 1, 1, 45,
|
252
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
253
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
254
|
+
1, 1, 9, 1, 46, 1, 1, 1,
|
255
|
+
47, 1, 1, 1, 1, 1, 1, 1,
|
256
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
257
|
+
1, 1, 1, 46, 1, 1, 1, 1,
|
258
|
+
1, 1, 1, 48, 1, 1, 1, 1,
|
259
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
260
|
+
1, 1, 1, 1, 1, 1, 49, 1,
|
261
|
+
9, 1, 1, 1, 50, 1, 1, 1,
|
262
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
263
|
+
1, 1, 1, 1, 1, 1, 1, 9,
|
264
|
+
1, 1, 1, 1, 1, 1, 1, 51,
|
265
|
+
1, 49, 1, 1, 1, 52, 1, 1,
|
266
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
267
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
268
|
+
49, 1, 1, 1, 1, 1, 1, 1,
|
269
|
+
53, 1, 1, 0,
|
270
|
+
]
|
271
|
+
|
272
|
+
class << self
|
273
|
+
attr_accessor :_trans_targs
|
274
|
+
private :_trans_targs, :_trans_targs=
|
275
|
+
end
|
276
|
+
self._trans_targs = [
|
277
|
+
1, 0, 2, 21, 8, 3, 5, 22,
|
278
|
+
7, 24, 1, 2, 21, 8, 10, 11,
|
279
|
+
10, 26, 13, 14, 15, 16, 17, 18,
|
280
|
+
19, 20, 10, 11, 10, 26, 13, 14,
|
281
|
+
15, 16, 17, 18, 19, 20, 12, 22,
|
282
|
+
4, 21, 23, 24, 4, 23, 22, 4,
|
283
|
+
23, 24, 6, 25, 6, 25,
|
284
|
+
]
|
285
|
+
|
286
|
+
class << self
|
287
|
+
attr_accessor :_trans_actions
|
288
|
+
private :_trans_actions, :_trans_actions=
|
289
|
+
end
|
290
|
+
self._trans_actions = [
|
291
|
+
0, 0, 0, 1, 2, 0, 0, 0,
|
292
|
+
0, 0, 3, 3, 4, 5, 6, 6,
|
293
|
+
7, 8, 6, 6, 6, 6, 6, 6,
|
294
|
+
6, 6, 0, 0, 2, 9, 0, 0,
|
295
|
+
0, 0, 0, 0, 0, 0, 0, 10,
|
296
|
+
10, 0, 11, 10, 0, 2, 3, 3,
|
297
|
+
5, 3, 0, 2, 3, 5,
|
298
|
+
]
|
14
299
|
|
300
|
+
class << self
|
301
|
+
attr_accessor :_eof_actions
|
302
|
+
private :_eof_actions, :_eof_actions=
|
303
|
+
end
|
304
|
+
self._eof_actions = [
|
305
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
306
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
307
|
+
0, 0, 0, 0, 0, 10, 0, 3,
|
308
|
+
0, 3, 0,
|
309
|
+
]
|
310
|
+
|
311
|
+
class << self
|
312
|
+
attr_accessor :start
|
313
|
+
end
|
314
|
+
self.start = 1
|
315
|
+
class << self
|
316
|
+
attr_accessor :first_final
|
317
|
+
end
|
318
|
+
self.first_final = 21
|
319
|
+
class << self
|
320
|
+
attr_accessor :error
|
321
|
+
end
|
322
|
+
self.error = 0
|
323
|
+
|
324
|
+
class << self
|
325
|
+
attr_accessor :en_comment_tail
|
326
|
+
end
|
327
|
+
self.en_comment_tail = 9
|
328
|
+
class << self
|
329
|
+
attr_accessor :en_main
|
330
|
+
end
|
331
|
+
self.en_main = 1
|
332
|
+
|
333
|
+
def self.parse(data)
|
334
|
+
data = data.dup.force_encoding(Encoding::ASCII_8BIT) if data.respond_to?(:force_encoding)
|
335
|
+
|
336
|
+
content_transfer_encoding = ContentTransferEncodingStruct.new("")
|
337
|
+
return content_transfer_encoding if Mail::Utilities.blank?(data)
|
338
|
+
|
339
|
+
# Parser state
|
15
340
|
encoding_s = nil
|
16
|
-
actions.each_slice(2) do |action_id, p|
|
17
|
-
action = Mail::Parsers::Ragel::ACTIONS[action_id]
|
18
|
-
case action
|
19
341
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
342
|
+
# 5.1 Variables Used by Ragel
|
343
|
+
p = 0
|
344
|
+
eof = pe = data.length
|
345
|
+
stack = []
|
24
346
|
|
25
|
-
|
26
|
-
|
347
|
+
begin
|
348
|
+
p ||= 0
|
349
|
+
pe ||= data.length
|
350
|
+
cs = start
|
351
|
+
top = 0
|
352
|
+
end
|
353
|
+
|
354
|
+
begin
|
355
|
+
testEof = false
|
356
|
+
_slen, _trans, _keys, _inds, _acts, _nacts = nil
|
357
|
+
_goto_level = 0
|
358
|
+
_resume = 10
|
359
|
+
_eof_trans = 15
|
360
|
+
_again = 20
|
361
|
+
_test_eof = 30
|
362
|
+
_out = 40
|
363
|
+
while true
|
364
|
+
if _goto_level <= 0
|
365
|
+
if p == pe
|
366
|
+
_goto_level = _test_eof
|
367
|
+
next
|
368
|
+
end
|
369
|
+
if cs == 0
|
370
|
+
_goto_level = _out
|
371
|
+
next
|
372
|
+
end
|
373
|
+
end
|
374
|
+
if _goto_level <= _resume
|
375
|
+
_keys = cs << 1
|
376
|
+
_inds = _index_offsets[cs]
|
377
|
+
_slen = _key_spans[cs]
|
378
|
+
_wide = data[p].ord
|
379
|
+
_trans = if (_slen > 0 &&
|
380
|
+
_trans_keys[_keys] <= _wide &&
|
381
|
+
_wide <= _trans_keys[_keys + 1])
|
382
|
+
_indicies[_inds + _wide - _trans_keys[_keys]]
|
383
|
+
else
|
384
|
+
_indicies[_inds + _slen]
|
385
|
+
end
|
386
|
+
cs = _trans_targs[_trans]
|
387
|
+
if _trans_actions[_trans] != 0
|
388
|
+
case _trans_actions[_trans]
|
389
|
+
when 1
|
390
|
+
begin
|
391
|
+
encoding_s = p
|
392
|
+
end
|
393
|
+
when 10
|
394
|
+
begin
|
395
|
+
content_transfer_encoding.encoding = chars(data, encoding_s, p - 1).downcase
|
396
|
+
end
|
397
|
+
when 3
|
398
|
+
begin
|
399
|
+
end
|
400
|
+
when 6
|
401
|
+
begin
|
402
|
+
end
|
403
|
+
when 2
|
404
|
+
begin
|
405
|
+
begin
|
406
|
+
stack[top] = cs
|
407
|
+
top += 1
|
408
|
+
cs = 9
|
409
|
+
_goto_level = _again
|
410
|
+
next
|
411
|
+
end
|
412
|
+
end
|
413
|
+
when 9
|
414
|
+
begin
|
415
|
+
begin
|
416
|
+
top -= 1
|
417
|
+
cs = stack[top]
|
418
|
+
_goto_level = _again
|
419
|
+
next
|
420
|
+
end
|
421
|
+
end
|
422
|
+
when 11
|
423
|
+
begin
|
424
|
+
content_transfer_encoding.encoding = chars(data, encoding_s, p - 1).downcase
|
425
|
+
end
|
426
|
+
begin
|
427
|
+
begin
|
428
|
+
stack[top] = cs
|
429
|
+
top += 1
|
430
|
+
cs = 9
|
431
|
+
_goto_level = _again
|
432
|
+
next
|
433
|
+
end
|
434
|
+
end
|
435
|
+
when 4
|
436
|
+
begin
|
437
|
+
end
|
438
|
+
begin
|
439
|
+
encoding_s = p
|
440
|
+
end
|
441
|
+
when 5
|
442
|
+
begin
|
443
|
+
end
|
444
|
+
begin
|
445
|
+
begin
|
446
|
+
stack[top] = cs
|
447
|
+
top += 1
|
448
|
+
cs = 9
|
449
|
+
_goto_level = _again
|
450
|
+
next
|
451
|
+
end
|
452
|
+
end
|
453
|
+
when 7
|
454
|
+
begin
|
455
|
+
end
|
456
|
+
begin
|
457
|
+
begin
|
458
|
+
stack[top] = cs
|
459
|
+
top += 1
|
460
|
+
cs = 9
|
461
|
+
_goto_level = _again
|
462
|
+
next
|
463
|
+
end
|
464
|
+
end
|
465
|
+
when 8
|
466
|
+
begin
|
467
|
+
end
|
468
|
+
begin
|
469
|
+
begin
|
470
|
+
top -= 1
|
471
|
+
cs = stack[top]
|
472
|
+
_goto_level = _again
|
473
|
+
next
|
474
|
+
end
|
475
|
+
end
|
476
|
+
end
|
477
|
+
end
|
478
|
+
end
|
479
|
+
if _goto_level <= _again
|
480
|
+
if cs == 0
|
481
|
+
_goto_level = _out
|
482
|
+
next
|
483
|
+
end
|
484
|
+
p += 1
|
485
|
+
if p != pe
|
486
|
+
_goto_level = _resume
|
487
|
+
next
|
488
|
+
end
|
489
|
+
end
|
490
|
+
if _goto_level <= _test_eof
|
491
|
+
if p == eof
|
492
|
+
case _eof_actions[cs]
|
493
|
+
when 10
|
494
|
+
begin
|
495
|
+
content_transfer_encoding.encoding = chars(data, encoding_s, p - 1).downcase
|
496
|
+
end
|
497
|
+
when 3
|
498
|
+
begin
|
499
|
+
end
|
500
|
+
end
|
501
|
+
end
|
502
|
+
end
|
503
|
+
if _goto_level <= _out
|
504
|
+
break
|
505
|
+
end
|
27
506
|
end
|
28
507
|
end
|
29
508
|
|
509
|
+
if p != eof || cs < 21
|
510
|
+
raise Mail::Field::IncompleteParseError.new(Mail::ContentTransferEncodingElement, data, p)
|
511
|
+
end
|
512
|
+
|
30
513
|
content_transfer_encoding
|
31
514
|
end
|
32
515
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'mail/utilities'
|
3
|
+
require 'mail/parser_tools'
|
4
|
+
|
5
|
+
%%{
|
6
|
+
machine content_transfer_encoding;
|
7
|
+
alphtype int;
|
8
|
+
|
9
|
+
action encoding_s { encoding_s = p }
|
10
|
+
action encoding_e { content_transfer_encoding.encoding = chars(data, encoding_s, p-1).downcase }
|
11
|
+
|
12
|
+
# No-op actions
|
13
|
+
action comment_e { }
|
14
|
+
action comment_s { }
|
15
|
+
action phrase_e { }
|
16
|
+
action phrase_s { }
|
17
|
+
action qstr_e { }
|
18
|
+
action qstr_s { }
|
19
|
+
action param_attr_e { }
|
20
|
+
action param_attr_s { }
|
21
|
+
action param_val_e { }
|
22
|
+
action param_val_s { }
|
23
|
+
action main_type_e { }
|
24
|
+
action main_type_s { }
|
25
|
+
action sub_type_e { }
|
26
|
+
action sub_type_s { }
|
27
|
+
|
28
|
+
include rfc2045_content_transfer_encoding "rfc2045_content_transfer_encoding.rl";
|
29
|
+
main := content_transfer_encoding;
|
30
|
+
}%%
|
31
|
+
|
32
|
+
module Mail::Parsers
|
33
|
+
module ContentTransferEncodingParser
|
34
|
+
extend Mail::ParserTools
|
35
|
+
|
36
|
+
ContentTransferEncodingStruct = Struct.new(:encoding, :error)
|
37
|
+
|
38
|
+
%%write data noprefix;
|
39
|
+
|
40
|
+
def self.parse(data)
|
41
|
+
data = data.dup.force_encoding(Encoding::ASCII_8BIT) if data.respond_to?(:force_encoding)
|
42
|
+
|
43
|
+
content_transfer_encoding = ContentTransferEncodingStruct.new('')
|
44
|
+
return content_transfer_encoding if Mail::Utilities.blank?(data)
|
45
|
+
|
46
|
+
# Parser state
|
47
|
+
encoding_s = nil
|
48
|
+
|
49
|
+
# 5.1 Variables Used by Ragel
|
50
|
+
p = 0
|
51
|
+
eof = pe = data.length
|
52
|
+
stack = []
|
53
|
+
|
54
|
+
%%write init;
|
55
|
+
%%write exec;
|
56
|
+
|
57
|
+
if p != eof || cs < %%{ write first_final; }%%
|
58
|
+
raise Mail::Field::IncompleteParseError.new(Mail::ContentTransferEncodingElement, data, p)
|
59
|
+
end
|
60
|
+
|
61
|
+
content_transfer_encoding
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|