mail 2.6.6 → 2.8.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 +134 -119
- data/lib/mail/attachments_list.rb +10 -9
- data/lib/mail/body.rb +73 -84
- data/lib/mail/check_delivery_params.rb +28 -21
- data/lib/mail/configuration.rb +2 -0
- data/lib/mail/constants.rb +27 -5
- data/lib/mail/elements/address.rb +53 -47
- data/lib/mail/elements/address_list.rb +11 -19
- data/lib/mail/elements/content_disposition_element.rb +9 -16
- data/lib/mail/elements/content_location_element.rb +6 -11
- data/lib/mail/elements/content_transfer_encoding_element.rb +6 -11
- data/lib/mail/elements/content_type_element.rb +16 -23
- data/lib/mail/elements/date_time_element.rb +7 -15
- data/lib/mail/elements/envelope_from_element.rb +22 -23
- data/lib/mail/elements/message_ids_element.rb +18 -13
- data/lib/mail/elements/mime_version_element.rb +7 -15
- data/lib/mail/elements/phrase_list.rb +12 -10
- data/lib/mail/elements/received_element.rb +27 -19
- data/lib/mail/encodings/7bit.rb +9 -14
- data/lib/mail/encodings/8bit.rb +2 -21
- data/lib/mail/encodings/base64.rb +11 -12
- data/lib/mail/encodings/binary.rb +3 -22
- data/lib/mail/encodings/identity.rb +24 -0
- data/lib/mail/encodings/quoted_printable.rb +6 -6
- data/lib/mail/encodings/transfer_encoding.rb +38 -29
- data/lib/mail/encodings/unix_to_unix.rb +3 -1
- data/lib/mail/encodings.rb +81 -54
- data/lib/mail/envelope.rb +11 -14
- data/lib/mail/field.rb +119 -98
- data/lib/mail/field_list.rb +60 -7
- data/lib/mail/fields/bcc_field.rb +34 -52
- data/lib/mail/fields/cc_field.rb +28 -49
- data/lib/mail/fields/comments_field.rb +27 -37
- data/lib/mail/fields/common_address_field.rb +170 -0
- data/lib/mail/fields/common_date_field.rb +58 -0
- data/lib/mail/fields/common_field.rb +77 -0
- data/lib/mail/fields/common_message_id_field.rb +42 -0
- data/lib/mail/fields/content_description_field.rb +7 -14
- data/lib/mail/fields/content_disposition_field.rb +13 -38
- data/lib/mail/fields/content_id_field.rb +24 -51
- data/lib/mail/fields/content_location_field.rb +11 -25
- data/lib/mail/fields/content_transfer_encoding_field.rb +31 -31
- data/lib/mail/fields/content_type_field.rb +50 -80
- data/lib/mail/fields/date_field.rb +23 -52
- data/lib/mail/fields/from_field.rb +28 -49
- data/lib/mail/fields/in_reply_to_field.rb +38 -49
- data/lib/mail/fields/keywords_field.rb +18 -31
- data/lib/mail/fields/message_id_field.rb +25 -71
- data/lib/mail/fields/mime_version_field.rb +19 -30
- data/lib/mail/fields/named_structured_field.rb +11 -0
- data/lib/mail/fields/named_unstructured_field.rb +11 -0
- data/lib/mail/fields/optional_field.rb +9 -7
- data/lib/mail/fields/{common/parameter_hash.rb → parameter_hash.rb} +13 -11
- data/lib/mail/fields/received_field.rb +43 -57
- data/lib/mail/fields/references_field.rb +35 -49
- data/lib/mail/fields/reply_to_field.rb +28 -49
- data/lib/mail/fields/resent_bcc_field.rb +28 -49
- data/lib/mail/fields/resent_cc_field.rb +28 -49
- data/lib/mail/fields/resent_date_field.rb +5 -30
- data/lib/mail/fields/resent_from_field.rb +28 -49
- data/lib/mail/fields/resent_message_id_field.rb +5 -29
- data/lib/mail/fields/resent_sender_field.rb +27 -56
- data/lib/mail/fields/resent_to_field.rb +28 -49
- data/lib/mail/fields/return_path_field.rb +50 -54
- data/lib/mail/fields/sender_field.rb +34 -55
- data/lib/mail/fields/structured_field.rb +3 -30
- data/lib/mail/fields/subject_field.rb +9 -11
- data/lib/mail/fields/to_field.rb +28 -49
- data/lib/mail/fields/unstructured_field.rb +32 -47
- data/lib/mail/header.rb +71 -110
- data/lib/mail/mail.rb +2 -10
- data/lib/mail/matchers/attachment_matchers.rb +15 -0
- data/lib/mail/matchers/has_sent_mail.rb +21 -1
- data/lib/mail/message.rb +113 -117
- data/lib/mail/multibyte/chars.rb +21 -178
- data/lib/mail/multibyte/unicode.rb +10 -10
- data/lib/mail/multibyte/utils.rb +26 -43
- data/lib/mail/multibyte.rb +55 -16
- data/lib/mail/network/delivery_methods/exim.rb +5 -4
- data/lib/mail/network/delivery_methods/file_delivery.rb +11 -10
- data/lib/mail/network/delivery_methods/logger_delivery.rb +34 -0
- data/lib/mail/network/delivery_methods/sendmail.rb +62 -21
- data/lib/mail/network/delivery_methods/smtp.rb +75 -50
- data/lib/mail/network/delivery_methods/smtp_connection.rb +3 -4
- data/lib/mail/network/delivery_methods/test_mailer.rb +4 -2
- data/lib/mail/network/retriever_methods/base.rb +8 -8
- data/lib/mail/network/retriever_methods/imap.rb +20 -7
- data/lib/mail/network/retriever_methods/pop3.rb +5 -3
- data/lib/mail/network/retriever_methods/test_retriever.rb +2 -1
- data/lib/mail/network.rb +1 -0
- data/lib/mail/parser_tools.rb +15 -0
- data/lib/mail/parsers/address_lists_parser.rb +33225 -116
- data/lib/mail/parsers/address_lists_parser.rl +179 -0
- data/lib/mail/parsers/content_disposition_parser.rb +882 -49
- data/lib/mail/parsers/content_disposition_parser.rl +89 -0
- data/lib/mail/parsers/content_location_parser.rb +809 -23
- data/lib/mail/parsers/content_location_parser.rl +78 -0
- data/lib/mail/parsers/content_transfer_encoding_parser.rb +509 -21
- data/lib/mail/parsers/content_transfer_encoding_parser.rl +71 -0
- data/lib/mail/parsers/content_type_parser.rb +1037 -56
- data/lib/mail/parsers/content_type_parser.rl +90 -0
- data/lib/mail/parsers/date_time_parser.rb +877 -25
- data/lib/mail/parsers/date_time_parser.rl +69 -0
- data/lib/mail/parsers/envelope_from_parser.rb +3669 -40
- data/lib/mail/parsers/envelope_from_parser.rl +89 -0
- data/lib/mail/parsers/message_ids_parser.rb +5146 -25
- data/lib/mail/parsers/message_ids_parser.rl +93 -0
- data/lib/mail/parsers/mime_version_parser.rb +497 -26
- data/lib/mail/parsers/mime_version_parser.rl +68 -0
- data/lib/mail/parsers/phrase_lists_parser.rb +870 -22
- data/lib/mail/parsers/phrase_lists_parser.rl +90 -0
- data/lib/mail/parsers/received_parser.rb +8776 -43
- data/lib/mail/parsers/received_parser.rl +91 -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 +74 -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 +11 -25
- data/lib/mail/part.rb +6 -10
- data/lib/mail/parts_list.rb +62 -6
- data/lib/mail/smtp_envelope.rb +57 -0
- data/lib/mail/utilities.rb +343 -74
- data/lib/mail/version.rb +2 -2
- data/lib/mail/yaml.rb +30 -0
- data/lib/mail.rb +5 -35
- metadata +111 -66
- data/CHANGELOG.rdoc +0 -803
- data/CONTRIBUTING.md +0 -60
- data/Dependencies.txt +0 -2
- data/Gemfile +0 -14
- data/Rakefile +0 -29
- data/TODO.rdoc +0 -9
- data/lib/mail/core_extensions/smtp.rb +0 -25
- data/lib/mail/core_extensions/string/access.rb +0 -146
- data/lib/mail/core_extensions/string/multibyte.rb +0 -79
- data/lib/mail/core_extensions/string.rb +0 -21
- data/lib/mail/fields/common/address_container.rb +0 -17
- data/lib/mail/fields/common/common_address.rb +0 -136
- data/lib/mail/fields/common/common_date.rb +0 -36
- data/lib/mail/fields/common/common_field.rb +0 -61
- data/lib/mail/fields/common/common_message_id.rb +0 -49
- data/lib/mail/multibyte/exceptions.rb +0 -9
- 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/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
- data/lib/mail/parsers/ragel/ruby.rb +0 -40
- data/lib/mail/parsers/ragel.rb +0 -18
- data/lib/mail/version_specific/ruby_1_8.rb +0 -126
- data/lib/mail/version_specific/ruby_1_9.rb +0 -226
@@ -0,0 +1,93 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'mail/utilities'
|
3
|
+
require 'mail/parser_tools'
|
4
|
+
|
5
|
+
begin
|
6
|
+
original_verbose, $VERBOSE = $VERBOSE, nil
|
7
|
+
|
8
|
+
%%{
|
9
|
+
# RFC 5322 Section 3.6.4: Identification Fields
|
10
|
+
# https://tools.ietf.org/html/rfc5322#section-3.6.4
|
11
|
+
machine message_ids;
|
12
|
+
alphtype int;
|
13
|
+
|
14
|
+
# Message Ids
|
15
|
+
action msg_id_s { msg_id_s = p }
|
16
|
+
action msg_id_e {
|
17
|
+
id = chars(data, msg_id_s, p-1)
|
18
|
+
id = $1 if id =~ /.*<(.*)>.*/
|
19
|
+
message_ids.message_ids << id
|
20
|
+
}
|
21
|
+
|
22
|
+
# No-op actions
|
23
|
+
action angle_addr_s {}
|
24
|
+
action address_s {}
|
25
|
+
action address_e {}
|
26
|
+
action comment_e {}
|
27
|
+
action comment_s {}
|
28
|
+
action domain_e {}
|
29
|
+
action domain_s {}
|
30
|
+
action local_dot_atom_e {}
|
31
|
+
action local_dot_atom_pre_comment_e {}
|
32
|
+
action local_dot_atom_pre_comment_s {}
|
33
|
+
action local_dot_atom_s {}
|
34
|
+
action phrase_s {}
|
35
|
+
action phrase_e {}
|
36
|
+
action qstr_e {}
|
37
|
+
action qstr_s {}
|
38
|
+
action ctime_date_s {}
|
39
|
+
action ctime_date_e {}
|
40
|
+
action date_s {}
|
41
|
+
action date_e {}
|
42
|
+
action time_s {}
|
43
|
+
action time_e {}
|
44
|
+
action local_quoted_string_s {}
|
45
|
+
action local_quoted_string_e {}
|
46
|
+
action obs_domain_list_s {}
|
47
|
+
action obs_domain_list_e {}
|
48
|
+
action group_name_s {}
|
49
|
+
action group_name_e {}
|
50
|
+
action received_tokens_s {}
|
51
|
+
action received_tokens_e {}
|
52
|
+
|
53
|
+
include rfc5322 "rfc5322.rl";
|
54
|
+
main := message_ids;
|
55
|
+
}%%
|
56
|
+
|
57
|
+
module Mail::Parsers
|
58
|
+
module MessageIdsParser
|
59
|
+
extend Mail::ParserTools
|
60
|
+
|
61
|
+
MessageIdsStruct = Struct.new(:message_ids, :error)
|
62
|
+
|
63
|
+
%%write data noprefix;
|
64
|
+
|
65
|
+
def self.parse(data)
|
66
|
+
data = data.dup.force_encoding(Encoding::ASCII_8BIT) if data.respond_to?(:force_encoding)
|
67
|
+
|
68
|
+
raise Mail::Field::NilParseError.new(Mail::MessageIdsElement) if data.nil?
|
69
|
+
|
70
|
+
# Parser state
|
71
|
+
message_ids = MessageIdsStruct.new([])
|
72
|
+
msg_id_s = nil
|
73
|
+
|
74
|
+
# 5.1 Variables Used by Ragel
|
75
|
+
p = 0
|
76
|
+
eof = pe = data.length
|
77
|
+
stack = []
|
78
|
+
|
79
|
+
%%write init;
|
80
|
+
%%write exec;
|
81
|
+
|
82
|
+
if p != eof || cs < %%{ write first_final; }%%
|
83
|
+
raise Mail::Field::IncompleteParseError.new(Mail::MessageIdsElement, data, p)
|
84
|
+
end
|
85
|
+
|
86
|
+
message_ids
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
ensure
|
92
|
+
$VERBOSE = original_verbose
|
93
|
+
end
|
@@ -1,42 +1,513 @@
|
|
1
|
+
|
1
2
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
|
4
|
-
|
3
|
+
require "mail/utilities"
|
4
|
+
require "mail/parser_tools"
|
5
|
+
|
6
|
+
begin
|
7
|
+
original_verbose, $VERBOSE = $VERBOSE, nil
|
8
|
+
|
9
|
+
module Mail::Parsers
|
10
|
+
module MimeVersionParser
|
11
|
+
extend Mail::ParserTools
|
12
|
+
|
13
|
+
MimeVersionStruct = Struct.new(:major, :minor, :error)
|
5
14
|
|
6
|
-
|
7
|
-
|
8
|
-
|
15
|
+
class << self
|
16
|
+
attr_accessor :_trans_keys
|
17
|
+
private :_trans_keys, :_trans_keys=
|
9
18
|
end
|
19
|
+
self._trans_keys = [
|
20
|
+
0, 0, 9, 57, 10, 10,
|
21
|
+
9, 32, 9, 57, 40,
|
22
|
+
57, 46, 46, 40, 57,
|
23
|
+
48, 57, 10, 10, 9, 32,
|
24
|
+
1, 244, 1, 244, 10,
|
25
|
+
10, 9, 32, 0, 244,
|
26
|
+
128, 191, 160, 191, 128, 191,
|
27
|
+
128, 159, 144, 191, 128,
|
28
|
+
191, 128, 143, 9, 57,
|
29
|
+
9, 40, 9, 40, 0, 0,
|
30
|
+
0,
|
31
|
+
]
|
10
32
|
|
11
|
-
|
33
|
+
class << self
|
34
|
+
attr_accessor :_key_spans
|
35
|
+
private :_key_spans, :_key_spans=
|
36
|
+
end
|
37
|
+
self._key_spans = [
|
38
|
+
0, 49, 1, 24, 49, 18, 1, 18,
|
39
|
+
10, 1, 24, 244, 244, 1, 24, 245,
|
40
|
+
64, 32, 64, 32, 48, 64, 16, 49,
|
41
|
+
32, 32, 0,
|
42
|
+
]
|
12
43
|
|
13
|
-
|
14
|
-
|
15
|
-
|
44
|
+
class << self
|
45
|
+
attr_accessor :_index_offsets
|
46
|
+
private :_index_offsets, :_index_offsets=
|
16
47
|
end
|
48
|
+
self._index_offsets = [
|
49
|
+
0, 0, 50, 52, 77, 127, 146, 148,
|
50
|
+
167, 178, 180, 205, 450, 695, 697, 722,
|
51
|
+
968, 1033, 1066, 1131, 1164, 1213, 1278, 1295,
|
52
|
+
1345, 1378, 1411,
|
53
|
+
]
|
17
54
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
55
|
+
class << self
|
56
|
+
attr_accessor :_indicies
|
57
|
+
private :_indicies, :_indicies=
|
58
|
+
end
|
59
|
+
self._indicies = [
|
60
|
+
0, 1, 1, 1, 2, 1, 1, 1,
|
61
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
62
|
+
1, 1, 1, 1, 1, 1, 1, 0,
|
63
|
+
1, 1, 1, 1, 1, 1, 1, 3,
|
64
|
+
1, 1, 1, 1, 1, 1, 1, 4,
|
65
|
+
4, 4, 4, 4, 4, 4, 4, 4,
|
66
|
+
4, 1, 5, 1, 0, 1, 1, 1,
|
67
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
68
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
69
|
+
1, 1, 1, 0, 1, 6, 1, 1,
|
70
|
+
1, 7, 1, 1, 1, 1, 1, 1,
|
71
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
72
|
+
1, 1, 1, 1, 6, 1, 1, 1,
|
73
|
+
1, 1, 1, 1, 8, 1, 1, 1,
|
74
|
+
1, 1, 1, 1, 9, 9, 9, 9,
|
75
|
+
9, 9, 9, 9, 9, 9, 1, 10,
|
76
|
+
1, 1, 1, 1, 1, 11, 1, 12,
|
77
|
+
12, 12, 12, 12, 12, 12, 12, 12,
|
78
|
+
12, 1, 13, 1, 14, 1, 1, 1,
|
79
|
+
1, 1, 1, 1, 15, 15, 15, 15,
|
80
|
+
15, 15, 15, 15, 15, 15, 1, 16,
|
81
|
+
16, 16, 16, 16, 16, 16, 16, 16,
|
82
|
+
16, 1, 17, 1, 18, 1, 1, 1,
|
83
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
84
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
85
|
+
1, 1, 1, 18, 1, 19, 19, 19,
|
86
|
+
19, 19, 19, 19, 19, 19, 1, 19,
|
87
|
+
19, 20, 19, 19, 19, 19, 19, 19,
|
88
|
+
19, 19, 19, 19, 19, 19, 19, 19,
|
89
|
+
19, 19, 19, 19, 19, 19, 19, 19,
|
90
|
+
19, 19, 19, 19, 21, 22, 19, 19,
|
91
|
+
19, 19, 19, 19, 19, 19, 19, 19,
|
92
|
+
19, 19, 19, 19, 19, 19, 19, 19,
|
93
|
+
19, 19, 19, 19, 19, 19, 19, 19,
|
94
|
+
19, 19, 19, 19, 19, 19, 19, 19,
|
95
|
+
19, 19, 19, 19, 19, 19, 19, 19,
|
96
|
+
19, 19, 19, 19, 19, 19, 19, 19,
|
97
|
+
23, 19, 19, 19, 19, 19, 19, 19,
|
98
|
+
19, 19, 19, 19, 19, 19, 19, 19,
|
99
|
+
19, 19, 19, 19, 19, 19, 19, 19,
|
100
|
+
19, 19, 19, 19, 19, 19, 19, 19,
|
101
|
+
19, 19, 19, 19, 1, 1, 1, 1,
|
102
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
103
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
104
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
105
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
106
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
107
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
108
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
109
|
+
1, 1, 1, 1, 1, 1, 24, 24,
|
110
|
+
24, 24, 24, 24, 24, 24, 24, 24,
|
111
|
+
24, 24, 24, 24, 24, 24, 24, 24,
|
112
|
+
24, 24, 24, 24, 24, 24, 24, 24,
|
113
|
+
24, 24, 24, 24, 25, 26, 26, 26,
|
114
|
+
26, 26, 26, 26, 26, 26, 26, 26,
|
115
|
+
26, 27, 26, 26, 28, 29, 29, 29,
|
116
|
+
30, 1, 31, 31, 31, 31, 31, 31,
|
117
|
+
31, 31, 31, 1, 31, 31, 32, 31,
|
118
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
119
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
120
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
121
|
+
31, 33, 34, 31, 31, 31, 31, 31,
|
122
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
123
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
124
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
125
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
126
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
127
|
+
31, 31, 31, 31, 31, 35, 31, 31,
|
128
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
129
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
130
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
131
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
132
|
+
31, 1, 1, 1, 1, 1, 1, 1,
|
133
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
134
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
135
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
136
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
137
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
138
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
139
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
140
|
+
1, 1, 1, 36, 36, 36, 36, 36,
|
141
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
142
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
143
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
144
|
+
36, 37, 38, 38, 38, 38, 38, 38,
|
145
|
+
38, 38, 38, 38, 38, 38, 39, 38,
|
146
|
+
38, 40, 41, 41, 41, 42, 1, 43,
|
147
|
+
1, 31, 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
|
+
31, 1, 31, 31, 31, 31, 31, 31,
|
151
|
+
31, 31, 31, 31, 31, 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, 31, 31, 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, 31, 31, 31, 31, 31,
|
160
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
161
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
162
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
163
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
164
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
165
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
166
|
+
31, 31, 1, 1, 1, 1, 1, 1,
|
167
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
168
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
169
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
170
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
171
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
172
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
173
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
174
|
+
1, 1, 1, 1, 36, 36, 36, 36,
|
175
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
176
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
177
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
178
|
+
36, 36, 37, 38, 38, 38, 38, 38,
|
179
|
+
38, 38, 38, 38, 38, 38, 38, 39,
|
180
|
+
38, 38, 40, 41, 41, 41, 42, 1,
|
181
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
182
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
183
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
184
|
+
31, 31, 31, 31, 31, 31, 31, 31,
|
185
|
+
31, 31, 31, 31, 31, 31, 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
|
+
1, 36, 36, 36, 36, 36, 36, 36,
|
190
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
191
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
192
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
193
|
+
36, 1, 36, 36, 36, 36, 36, 36,
|
194
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
195
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
196
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
197
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
198
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
199
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
200
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
201
|
+
36, 36, 1, 36, 36, 36, 36, 36,
|
202
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
203
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
204
|
+
36, 36, 36, 36, 36, 36, 36, 36,
|
205
|
+
36, 36, 36, 1, 38, 38, 38, 38,
|
206
|
+
38, 38, 38, 38, 38, 38, 38, 38,
|
207
|
+
38, 38, 38, 38, 38, 38, 38, 38,
|
208
|
+
38, 38, 38, 38, 38, 38, 38, 38,
|
209
|
+
38, 38, 38, 38, 38, 38, 38, 38,
|
210
|
+
38, 38, 38, 38, 38, 38, 38, 38,
|
211
|
+
38, 38, 38, 38, 1, 38, 38, 38,
|
212
|
+
38, 38, 38, 38, 38, 38, 38, 38,
|
213
|
+
38, 38, 38, 38, 38, 38, 38, 38,
|
214
|
+
38, 38, 38, 38, 38, 38, 38, 38,
|
215
|
+
38, 38, 38, 38, 38, 38, 38, 38,
|
216
|
+
38, 38, 38, 38, 38, 38, 38, 38,
|
217
|
+
38, 38, 38, 38, 38, 38, 38, 38,
|
218
|
+
38, 38, 38, 38, 38, 38, 38, 38,
|
219
|
+
38, 38, 38, 38, 38, 1, 38, 38,
|
220
|
+
38, 38, 38, 38, 38, 38, 38, 38,
|
221
|
+
38, 38, 38, 38, 38, 38, 1, 44,
|
222
|
+
1, 1, 1, 45, 1, 1, 1, 1,
|
223
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
224
|
+
1, 1, 1, 1, 1, 1, 44, 1,
|
225
|
+
1, 1, 1, 1, 1, 1, 46, 1,
|
226
|
+
1, 1, 1, 1, 1, 1, 47, 47,
|
227
|
+
47, 47, 47, 47, 47, 47, 47, 47,
|
228
|
+
1, 18, 1, 1, 1, 48, 1, 1,
|
229
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
230
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
231
|
+
18, 1, 1, 1, 1, 1, 1, 1,
|
232
|
+
49, 1, 50, 1, 1, 1, 51, 1,
|
233
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
234
|
+
1, 1, 1, 1, 1, 1, 1, 1,
|
235
|
+
1, 50, 1, 1, 1, 1, 1, 1,
|
236
|
+
1, 52, 1, 1, 0,
|
237
|
+
]
|
22
238
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
239
|
+
class << self
|
240
|
+
attr_accessor :_trans_targs
|
241
|
+
private :_trans_targs, :_trans_targs=
|
242
|
+
end
|
243
|
+
self._trans_targs = [
|
244
|
+
1, 0, 2, 4, 5, 3, 1, 2,
|
245
|
+
4, 5, 6, 7, 5, 7, 8, 23,
|
246
|
+
23, 10, 24, 12, 13, 12, 26, 15,
|
247
|
+
16, 17, 18, 19, 20, 21, 22, 12,
|
248
|
+
13, 12, 26, 15, 16, 17, 18, 19,
|
249
|
+
20, 21, 22, 14, 24, 9, 25, 23,
|
250
|
+
9, 25, 24, 9, 25,
|
251
|
+
]
|
27
252
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
253
|
+
class << self
|
254
|
+
attr_accessor :_trans_actions
|
255
|
+
private :_trans_actions, :_trans_actions=
|
256
|
+
end
|
257
|
+
self._trans_actions = [
|
258
|
+
0, 0, 0, 1, 2, 0, 3, 3,
|
259
|
+
4, 5, 6, 7, 0, 3, 1, 8,
|
260
|
+
9, 0, 0, 10, 10, 11, 12, 10,
|
261
|
+
10, 10, 10, 10, 10, 10, 10, 0,
|
262
|
+
0, 1, 13, 0, 0, 0, 0, 0,
|
263
|
+
0, 0, 0, 0, 14, 14, 15, 0,
|
264
|
+
0, 1, 3, 3, 4,
|
265
|
+
]
|
266
|
+
|
267
|
+
class << self
|
268
|
+
attr_accessor :_eof_actions
|
269
|
+
private :_eof_actions, :_eof_actions=
|
270
|
+
end
|
271
|
+
self._eof_actions = [
|
272
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
273
|
+
0, 0, 0, 0, 0, 0, 0, 0,
|
274
|
+
0, 0, 0, 0, 0, 0, 0, 14,
|
275
|
+
0, 3, 0,
|
276
|
+
]
|
32
277
|
|
33
|
-
|
278
|
+
class << self
|
279
|
+
attr_accessor :start
|
280
|
+
end
|
281
|
+
self.start = 1
|
282
|
+
class << self
|
283
|
+
attr_accessor :first_final
|
284
|
+
end
|
285
|
+
self.first_final = 23
|
286
|
+
class << self
|
287
|
+
attr_accessor :error
|
288
|
+
end
|
289
|
+
self.error = 0
|
34
290
|
|
35
|
-
|
36
|
-
|
291
|
+
class << self
|
292
|
+
attr_accessor :en_comment_tail
|
293
|
+
end
|
294
|
+
self.en_comment_tail = 11
|
295
|
+
class << self
|
296
|
+
attr_accessor :en_main
|
297
|
+
end
|
298
|
+
self.en_main = 1
|
299
|
+
|
300
|
+
def self.parse(data)
|
301
|
+
data = data.dup.force_encoding(Encoding::ASCII_8BIT) if data.respond_to?(:force_encoding)
|
302
|
+
|
303
|
+
return MimeVersionStruct.new("", nil) if Mail::Utilities.blank?(data)
|
304
|
+
|
305
|
+
# Parser state
|
306
|
+
mime_version = MimeVersionStruct.new
|
307
|
+
major_digits_s = minor_digits_s = nil
|
308
|
+
|
309
|
+
# 5.1 Variables Used by Ragel
|
310
|
+
p = 0
|
311
|
+
eof = pe = data.length
|
312
|
+
stack = []
|
313
|
+
|
314
|
+
begin
|
315
|
+
p ||= 0
|
316
|
+
pe ||= data.length
|
317
|
+
cs = start
|
318
|
+
top = 0
|
319
|
+
end
|
320
|
+
|
321
|
+
begin
|
322
|
+
testEof = false
|
323
|
+
_slen, _trans, _keys, _inds, _acts, _nacts = nil
|
324
|
+
_goto_level = 0
|
325
|
+
_resume = 10
|
326
|
+
_eof_trans = 15
|
327
|
+
_again = 20
|
328
|
+
_test_eof = 30
|
329
|
+
_out = 40
|
330
|
+
while true
|
331
|
+
if _goto_level <= 0
|
332
|
+
if p == pe
|
333
|
+
_goto_level = _test_eof
|
334
|
+
next
|
335
|
+
end
|
336
|
+
if cs == 0
|
337
|
+
_goto_level = _out
|
338
|
+
next
|
339
|
+
end
|
340
|
+
end
|
341
|
+
if _goto_level <= _resume
|
342
|
+
_keys = cs << 1
|
343
|
+
_inds = _index_offsets[cs]
|
344
|
+
_slen = _key_spans[cs]
|
345
|
+
_wide = data[p].ord
|
346
|
+
_trans = if (_slen > 0 &&
|
347
|
+
_trans_keys[_keys] <= _wide &&
|
348
|
+
_wide <= _trans_keys[_keys + 1])
|
349
|
+
_indicies[_inds + _wide - _trans_keys[_keys]]
|
350
|
+
else
|
351
|
+
_indicies[_inds + _slen]
|
352
|
+
end
|
353
|
+
cs = _trans_targs[_trans]
|
354
|
+
if _trans_actions[_trans] != 0
|
355
|
+
case _trans_actions[_trans]
|
356
|
+
when 2
|
357
|
+
begin
|
358
|
+
major_digits_s = p
|
359
|
+
end
|
360
|
+
when 7
|
361
|
+
begin
|
362
|
+
mime_version.major = chars(data, major_digits_s, p - 1)
|
363
|
+
end
|
364
|
+
when 8
|
365
|
+
begin
|
366
|
+
minor_digits_s = p
|
367
|
+
end
|
368
|
+
when 14
|
369
|
+
begin
|
370
|
+
mime_version.minor = chars(data, minor_digits_s, p - 1)
|
371
|
+
end
|
372
|
+
when 10
|
373
|
+
begin
|
374
|
+
end
|
375
|
+
when 3
|
376
|
+
begin
|
377
|
+
end
|
378
|
+
when 1
|
379
|
+
begin
|
380
|
+
begin
|
381
|
+
stack[top] = cs
|
382
|
+
top += 1
|
383
|
+
cs = 11
|
384
|
+
_goto_level = _again
|
385
|
+
next
|
386
|
+
end
|
387
|
+
end
|
388
|
+
when 13
|
389
|
+
begin
|
390
|
+
begin
|
391
|
+
top -= 1
|
392
|
+
cs = stack[top]
|
393
|
+
_goto_level = _again
|
394
|
+
next
|
395
|
+
end
|
396
|
+
end
|
397
|
+
when 6
|
398
|
+
begin
|
399
|
+
mime_version.major = chars(data, major_digits_s, p - 1)
|
400
|
+
end
|
401
|
+
begin
|
402
|
+
begin
|
403
|
+
stack[top] = cs
|
404
|
+
top += 1
|
405
|
+
cs = 11
|
406
|
+
_goto_level = _again
|
407
|
+
next
|
408
|
+
end
|
409
|
+
end
|
410
|
+
when 15
|
411
|
+
begin
|
412
|
+
mime_version.minor = chars(data, minor_digits_s, p - 1)
|
413
|
+
end
|
414
|
+
begin
|
415
|
+
begin
|
416
|
+
stack[top] = cs
|
417
|
+
top += 1
|
418
|
+
cs = 11
|
419
|
+
_goto_level = _again
|
420
|
+
next
|
421
|
+
end
|
422
|
+
end
|
423
|
+
when 11
|
424
|
+
begin
|
425
|
+
end
|
426
|
+
begin
|
427
|
+
begin
|
428
|
+
stack[top] = cs
|
429
|
+
top += 1
|
430
|
+
cs = 11
|
431
|
+
_goto_level = _again
|
432
|
+
next
|
433
|
+
end
|
434
|
+
end
|
435
|
+
when 12
|
436
|
+
begin
|
437
|
+
end
|
438
|
+
begin
|
439
|
+
begin
|
440
|
+
top -= 1
|
441
|
+
cs = stack[top]
|
442
|
+
_goto_level = _again
|
443
|
+
next
|
444
|
+
end
|
445
|
+
end
|
446
|
+
when 5
|
447
|
+
begin
|
448
|
+
end
|
449
|
+
begin
|
450
|
+
major_digits_s = p
|
451
|
+
end
|
452
|
+
when 9
|
453
|
+
begin
|
454
|
+
end
|
455
|
+
begin
|
456
|
+
minor_digits_s = p
|
457
|
+
end
|
458
|
+
when 4
|
459
|
+
begin
|
460
|
+
end
|
461
|
+
begin
|
462
|
+
begin
|
463
|
+
stack[top] = cs
|
464
|
+
top += 1
|
465
|
+
cs = 11
|
466
|
+
_goto_level = _again
|
467
|
+
next
|
468
|
+
end
|
469
|
+
end
|
470
|
+
end
|
471
|
+
end
|
472
|
+
end
|
473
|
+
if _goto_level <= _again
|
474
|
+
if cs == 0
|
475
|
+
_goto_level = _out
|
476
|
+
next
|
477
|
+
end
|
478
|
+
p += 1
|
479
|
+
if p != pe
|
480
|
+
_goto_level = _resume
|
481
|
+
next
|
482
|
+
end
|
483
|
+
end
|
484
|
+
if _goto_level <= _test_eof
|
485
|
+
if p == eof
|
486
|
+
case _eof_actions[cs]
|
487
|
+
when 14
|
488
|
+
begin
|
489
|
+
mime_version.minor = chars(data, minor_digits_s, p - 1)
|
490
|
+
end
|
491
|
+
when 3
|
492
|
+
begin
|
493
|
+
end
|
494
|
+
end
|
495
|
+
end
|
496
|
+
end
|
497
|
+
if _goto_level <= _out
|
498
|
+
break
|
499
|
+
end
|
500
|
+
end
|
37
501
|
end
|
502
|
+
|
503
|
+
if p != eof || cs < 23
|
504
|
+
raise Mail::Field::IncompleteParseError.new(Mail::MimeVersionElement, data, p)
|
505
|
+
end
|
506
|
+
|
507
|
+
mime_version
|
38
508
|
end
|
39
|
-
mime_version
|
40
509
|
end
|
41
510
|
end
|
511
|
+
ensure
|
512
|
+
$VERBOSE = original_verbose
|
42
513
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'mail/utilities'
|
3
|
+
require 'mail/parser_tools'
|
4
|
+
|
5
|
+
begin
|
6
|
+
original_verbose, $VERBOSE = $VERBOSE, nil
|
7
|
+
|
8
|
+
%%{
|
9
|
+
machine mime_version;
|
10
|
+
alphtype int;
|
11
|
+
|
12
|
+
# Major Digits
|
13
|
+
action major_digits_s { major_digits_s = p }
|
14
|
+
action major_digits_e { mime_version.major = chars(data, major_digits_s, p-1) }
|
15
|
+
|
16
|
+
# Minor Digits
|
17
|
+
action minor_digits_s { minor_digits_s = p }
|
18
|
+
action minor_digits_e { mime_version.minor = chars(data, minor_digits_s, p-1) }
|
19
|
+
|
20
|
+
# No-op actions
|
21
|
+
action comment_s {}
|
22
|
+
action comment_e {}
|
23
|
+
action qstr_s {}
|
24
|
+
action qstr_e {}
|
25
|
+
action phrase_s {}
|
26
|
+
action phrase_e {}
|
27
|
+
|
28
|
+
include rfc2045_mime "rfc2045_mime.rl";
|
29
|
+
main := mime_version;
|
30
|
+
}%%
|
31
|
+
|
32
|
+
module Mail::Parsers
|
33
|
+
module MimeVersionParser
|
34
|
+
extend Mail::ParserTools
|
35
|
+
|
36
|
+
MimeVersionStruct = Struct.new(:major, :minor, :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
|
+
return MimeVersionStruct.new('', nil) if Mail::Utilities.blank?(data)
|
44
|
+
|
45
|
+
# Parser state
|
46
|
+
mime_version = MimeVersionStruct.new
|
47
|
+
major_digits_s = minor_digits_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::MimeVersionElement, data, p)
|
59
|
+
end
|
60
|
+
|
61
|
+
mime_version
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
ensure
|
67
|
+
$VERBOSE = original_verbose
|
68
|
+
end
|