mail 2.6.6 → 2.7.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,166 @@
1
+ # frozen_string_literal: true
2
+ require 'mail/utilities'
3
+
4
+ %%{
5
+ machine address_lists;
6
+
7
+ # Phrase
8
+ action phrase_s { phrase_s = p }
9
+ action phrase_e { phrase_e = p-1 }
10
+
11
+ # Quoted String.
12
+ action qstr_s { qstr_s = p }
13
+ action qstr_e { qstr = data[qstr_s..(p-1)] }
14
+
15
+ # Comment
16
+ action comment_s { comment_s = p unless comment_s }
17
+ action comment_e {
18
+ if address
19
+ address.comments << data[comment_s..(p-2)]
20
+ end
21
+ comment_s = nil
22
+ }
23
+
24
+ # Group Name
25
+ action group_name_s { group_name_s = p }
26
+ action group_name_e {
27
+ if qstr
28
+ group = qstr
29
+ qstr = nil
30
+ else
31
+ group = data[group_name_s..(p-1)]
32
+ group_name_s = nil
33
+ end
34
+ address_list.group_names << group
35
+ group_name = group
36
+
37
+ # Start next address
38
+ address = AddressStruct.new(nil, nil, [], nil, nil, nil, nil)
39
+ address_s = p
40
+ address.group = group_name
41
+ }
42
+
43
+ # Address
44
+ action address_s { address_s = p }
45
+ action address_e {
46
+ # Ignore address end events if they don't have
47
+ # a matching address start event.
48
+ if address_s
49
+ if address.local.nil? && local_dot_atom_pre_comment_e && local_dot_atom_s && local_dot_atom_e
50
+ if address.domain
51
+ address.local = data[local_dot_atom_s..local_dot_atom_e] if address
52
+ else
53
+ address.local = data[local_dot_atom_s..local_dot_atom_pre_comment_e] if address
54
+ end
55
+ end
56
+ address.raw = data[address_s..(p-1)]
57
+ address_list.addresses << address if address
58
+
59
+ # Start next address
60
+ address = AddressStruct.new(nil, nil, [], nil, nil, nil, nil)
61
+ address.group = group_name
62
+ address_s = nil
63
+ end
64
+ }
65
+
66
+ # Don't set the display name until the address has actually started. This
67
+ # allows us to choose quoted_s version if it exists and always use the
68
+ # 'full' phrase version.
69
+ action angle_addr_s {
70
+ if qstr
71
+ address.display_name = Mail::Utilities.unescape(qstr)
72
+ qstr = nil
73
+ elsif phrase_e
74
+ address.display_name = data[phrase_s..phrase_e].strip
75
+ phrase_e = phrase_s = nil
76
+ end
77
+ }
78
+
79
+ # Domain
80
+ action domain_s { domain_s = p }
81
+ action domain_e {
82
+ address.domain = data[domain_s..(p-1)].rstrip if address
83
+ }
84
+
85
+ # Local
86
+ action local_dot_atom_s { local_dot_atom_s = p }
87
+ action local_dot_atom_e { local_dot_atom_e = p-1 }
88
+ action local_dot_atom_pre_comment_e { local_dot_atom_pre_comment_e = p-1 }
89
+ action local_quoted_string_e { address.local = '"' + qstr + '"' if address }
90
+
91
+ # obs_domain_list
92
+ action obs_domain_list_s { obs_domain_list_s = p }
93
+ action obs_domain_list_e { address.obs_domain_list = data[obs_domain_list_s..(p-1)] }
94
+
95
+ # Junk actions
96
+ action addr_spec { }
97
+ action ctime_date_e { }
98
+ action ctime_date_s { }
99
+ action date_e { }
100
+ action date_s { }
101
+ action disp_type_e { }
102
+ action disp_type_s { }
103
+ action encoding_e { }
104
+ action encoding_s { }
105
+ action main_type_e { }
106
+ action main_type_s { }
107
+ action major_digits_e { }
108
+ action major_digits_s { }
109
+ action minor_digits_e { }
110
+ action minor_digits_s { }
111
+ action msg_id_e { }
112
+ action msg_id_s { }
113
+ action param_attr_e { }
114
+ action param_attr_s { }
115
+ action param_val_e { }
116
+ action param_val_s { }
117
+ action received_tokens_e { }
118
+ action received_tokens_s { }
119
+ action sub_type_e { }
120
+ action sub_type_s { }
121
+ action time_e { }
122
+ action time_s { }
123
+ action token_string_e { }
124
+ action token_string_s { }
125
+
126
+ include rfc5322 "rfc5322.rl";
127
+ main := address_lists;
128
+ }%%
129
+
130
+ module Mail::Parsers
131
+ module AddressListsParser
132
+ AddressListStruct = Struct.new(:addresses, :group_names, :error)
133
+ AddressStruct = Struct.new(:raw, :domain, :comments, :local,
134
+ :obs_domain_list, :display_name, :group, :error)
135
+
136
+ %%write data noprefix;
137
+
138
+ def self.parse(data)
139
+ address_list = AddressListStruct.new([], [])
140
+ return address_list if Mail::Utilities.blank?(data)
141
+
142
+ phrase_s = phrase_e = qstr_s = qstr = comment_s = nil
143
+ group_name_s = domain_s = group_name = nil
144
+ local_dot_atom_s = local_dot_atom_e = nil
145
+ local_dot_atom_pre_comment_e = nil
146
+ obs_domain_list_s = nil
147
+
148
+ address_s = 0
149
+ address = AddressStruct.new(nil, nil, [], nil, nil, nil, nil)
150
+
151
+ # 5.1 Variables Used by Ragel
152
+ p = 0
153
+ eof = pe = data.length
154
+ stack = []
155
+
156
+ %%write init;
157
+ %%write exec;
158
+
159
+ if p != eof || cs < %%{ write first_final; }%%
160
+ raise Mail::Field::ParseError.new(Mail::AddressList, data, "Only able to parse up to #{data[0..p]}")
161
+ end
162
+
163
+ address_list
164
+ end
165
+ end
166
+ end
@@ -1,68 +1,711 @@
1
+
1
2
  # frozen_string_literal: true
3
+ require 'mail/utilities'
4
+
5
+
6
+
7
+
2
8
  module Mail::Parsers
3
- class ContentDispositionParser
4
- include Mail::Utilities
9
+ module ContentDispositionParser
10
+ ContentDispositionStruct = Struct.new(:disposition_type, :parameters, :error)
5
11
 
6
- def parse(s)
7
- content_disposition = ContentDispositionStruct.new("", nil)
8
- if Mail::Utilities.blank?(s)
9
- return content_disposition
10
- end
12
+
13
+ class << self
14
+ attr_accessor :_trans_keys
15
+ private :_trans_keys, :_trans_keys=
16
+ end
17
+ self._trans_keys = [
18
+ 0, 0, 33, 126, 9, 126,
19
+ 10, 10, 9, 32, 33,
20
+ 126, 9, 126, 9, 40,
21
+ 10, 10, 9, 32, 1, 127,
22
+ 1, 127, 10, 10, 9,
23
+ 32, 10, 10, 9, 32,
24
+ -128, -1, 9, 40, 10, 10,
25
+ 9, 32, 9, 126, 1,
26
+ 127, 1, 127, 10, 10,
27
+ 9, 32, -128, -1, 33, 126,
28
+ 9, 59, 9, 59, 9,
29
+ 126, 9, 59, 9, 59,
30
+ 0, 0, 0
31
+ ]
11
32
 
12
- actions, error = Ragel.parse(:content_disposition, s)
13
- if error
14
- raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, s, error)
15
- end
33
+ class << self
34
+ attr_accessor :_key_spans
35
+ private :_key_spans, :_key_spans=
36
+ end
37
+ self._key_spans = [
38
+ 0, 94, 118, 1, 24, 94, 118, 32,
39
+ 1, 24, 127, 127, 1, 24, 1, 24,
40
+ 128, 32, 1, 24, 118, 127, 127, 1,
41
+ 24, 128, 94, 51, 51, 118, 51, 51,
42
+ 0
43
+ ]
16
44
 
17
- content_disposition.parameters = []
45
+ class << self
46
+ attr_accessor :_index_offsets
47
+ private :_index_offsets, :_index_offsets=
48
+ end
49
+ self._index_offsets = [
50
+ 0, 0, 95, 214, 216, 241, 336, 455,
51
+ 488, 490, 515, 643, 771, 773, 798, 800,
52
+ 825, 954, 987, 989, 1014, 1133, 1261, 1389,
53
+ 1391, 1416, 1545, 1640, 1692, 1744, 1863, 1915,
54
+ 1967
55
+ ]
56
+
57
+ class << self
58
+ attr_accessor :_indicies
59
+ private :_indicies, :_indicies=
60
+ end
61
+ self._indicies = [
62
+ 0, 0, 0, 0, 0, 0, 0, 1,
63
+ 1, 0, 0, 0, 0, 0, 1, 0,
64
+ 0, 0, 0, 0, 0, 0, 0, 0,
65
+ 0, 1, 1, 1, 1, 1, 1, 1,
66
+ 0, 0, 0, 0, 0, 0, 0, 0,
67
+ 0, 0, 0, 0, 0, 0, 0, 0,
68
+ 0, 0, 0, 0, 0, 0, 0, 0,
69
+ 0, 0, 1, 1, 1, 0, 0, 0,
70
+ 0, 0, 0, 0, 0, 0, 0, 0,
71
+ 0, 0, 0, 0, 0, 0, 0, 0,
72
+ 0, 0, 0, 0, 0, 0, 0, 0,
73
+ 0, 0, 0, 0, 0, 0, 1, 2,
74
+ 1, 1, 1, 3, 1, 1, 1, 1,
75
+ 1, 1, 1, 1, 1, 1, 1, 1,
76
+ 1, 1, 1, 1, 1, 1, 2, 4,
77
+ 4, 4, 4, 4, 4, 4, 5, 1,
78
+ 4, 4, 4, 4, 4, 1, 4, 4,
79
+ 4, 4, 4, 4, 4, 4, 4, 4,
80
+ 1, 1, 1, 1, 1, 1, 1, 4,
81
+ 4, 4, 4, 4, 4, 4, 4, 4,
82
+ 4, 4, 4, 4, 4, 4, 4, 4,
83
+ 4, 4, 4, 4, 4, 4, 4, 4,
84
+ 4, 1, 1, 1, 4, 4, 4, 4,
85
+ 4, 4, 4, 4, 4, 4, 4, 4,
86
+ 4, 4, 4, 4, 4, 4, 4, 4,
87
+ 4, 4, 4, 4, 4, 4, 4, 4,
88
+ 4, 4, 4, 4, 4, 1, 6, 1,
89
+ 2, 1, 1, 1, 1, 1, 1, 1,
90
+ 1, 1, 1, 1, 1, 1, 1, 1,
91
+ 1, 1, 1, 1, 1, 1, 1, 2,
92
+ 1, 7, 7, 7, 7, 7, 7, 7,
93
+ 1, 1, 7, 7, 7, 7, 7, 1,
94
+ 7, 7, 7, 7, 7, 7, 7, 7,
95
+ 7, 7, 1, 1, 1, 8, 1, 1,
96
+ 1, 7, 7, 7, 7, 7, 7, 7,
97
+ 7, 7, 7, 7, 7, 7, 7, 7,
98
+ 7, 7, 7, 7, 7, 7, 7, 7,
99
+ 7, 7, 7, 1, 1, 1, 7, 7,
100
+ 7, 7, 7, 7, 7, 7, 7, 7,
101
+ 7, 7, 7, 7, 7, 7, 7, 7,
102
+ 7, 7, 7, 7, 7, 7, 7, 7,
103
+ 7, 7, 7, 7, 7, 7, 7, 1,
104
+ 9, 1, 1, 1, 10, 1, 1, 1,
105
+ 1, 1, 1, 1, 1, 1, 1, 1,
106
+ 1, 1, 1, 1, 1, 1, 1, 9,
107
+ 11, 12, 11, 11, 11, 11, 11, 13,
108
+ 1, 11, 11, 11, 11, 11, 1, 11,
109
+ 11, 11, 11, 11, 11, 11, 11, 11,
110
+ 11, 1, 1, 1, 11, 1, 1, 1,
111
+ 11, 11, 11, 11, 11, 11, 11, 11,
112
+ 11, 11, 11, 11, 11, 11, 11, 11,
113
+ 11, 11, 11, 11, 11, 11, 11, 11,
114
+ 11, 11, 1, 1, 1, 11, 11, 11,
115
+ 11, 11, 11, 11, 11, 11, 11, 11,
116
+ 11, 11, 11, 11, 11, 11, 11, 11,
117
+ 11, 11, 11, 11, 11, 11, 11, 11,
118
+ 11, 11, 11, 11, 11, 11, 1, 14,
119
+ 1, 1, 1, 15, 1, 1, 1, 1,
120
+ 1, 1, 1, 1, 1, 1, 1, 1,
121
+ 1, 1, 1, 1, 1, 1, 14, 1,
122
+ 16, 1, 1, 1, 1, 1, 17, 1,
123
+ 18, 1, 14, 1, 1, 1, 1, 1,
124
+ 1, 1, 1, 1, 1, 1, 1, 1,
125
+ 1, 1, 1, 1, 1, 1, 1, 1,
126
+ 1, 14, 1, 19, 19, 19, 19, 19,
127
+ 19, 19, 19, 19, 1, 19, 19, 20,
128
+ 19, 19, 19, 19, 19, 19, 19, 19,
129
+ 19, 19, 19, 19, 19, 19, 19, 19,
130
+ 19, 19, 19, 19, 21, 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, 22, 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, 1, 23, 23, 23, 23, 23,
143
+ 23, 23, 23, 23, 1, 23, 23, 24,
144
+ 23, 23, 23, 23, 23, 23, 23, 23,
145
+ 23, 23, 23, 23, 23, 23, 23, 23,
146
+ 23, 23, 23, 23, 25, 23, 23, 23,
147
+ 23, 23, 23, 23, 23, 23, 23, 23,
148
+ 23, 23, 23, 23, 23, 23, 23, 23,
149
+ 23, 23, 23, 23, 23, 23, 23, 23,
150
+ 23, 23, 23, 23, 23, 23, 23, 23,
151
+ 23, 23, 23, 23, 23, 23, 23, 23,
152
+ 23, 23, 23, 23, 23, 23, 23, 23,
153
+ 23, 23, 23, 23, 23, 23, 26, 23,
154
+ 23, 23, 23, 23, 23, 23, 23, 23,
155
+ 23, 23, 23, 23, 23, 23, 23, 23,
156
+ 23, 23, 23, 23, 23, 23, 23, 23,
157
+ 23, 23, 23, 23, 23, 23, 23, 23,
158
+ 23, 23, 1, 27, 1, 23, 1, 1,
159
+ 1, 1, 1, 1, 1, 1, 1, 1,
160
+ 1, 1, 1, 1, 1, 1, 1, 1,
161
+ 1, 1, 1, 1, 23, 1, 28, 1,
162
+ 29, 1, 1, 1, 1, 1, 1, 1,
163
+ 1, 1, 1, 1, 1, 1, 1, 1,
164
+ 1, 1, 1, 1, 1, 1, 1, 29,
165
+ 1, 1, 1, 1, 1, 1, 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, 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, 1, 1, 1, 1,
175
+ 1, 1, 1, 1, 1, 1, 1, 1,
176
+ 1, 1, 1, 1, 1, 1, 1, 1,
177
+ 1, 1, 1, 1, 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, 23, 30, 1, 1, 1, 31, 1,
182
+ 1, 1, 1, 1, 1, 1, 1, 1,
183
+ 1, 1, 1, 1, 1, 1, 1, 1,
184
+ 1, 30, 1, 32, 1, 1, 1, 1,
185
+ 1, 33, 1, 34, 1, 35, 1, 1,
186
+ 1, 1, 1, 1, 1, 1, 1, 1,
187
+ 1, 1, 1, 1, 1, 1, 1, 1,
188
+ 1, 1, 1, 1, 35, 1, 36, 1,
189
+ 1, 1, 37, 1, 1, 1, 1, 1,
190
+ 1, 1, 1, 1, 1, 1, 1, 1,
191
+ 1, 1, 1, 1, 1, 36, 38, 38,
192
+ 38, 38, 38, 38, 38, 39, 1, 38,
193
+ 38, 38, 38, 38, 1, 38, 38, 38,
194
+ 38, 38, 38, 38, 38, 38, 38, 1,
195
+ 1, 1, 1, 1, 1, 1, 38, 38,
196
+ 38, 38, 38, 38, 38, 38, 38, 38,
197
+ 38, 38, 38, 38, 38, 38, 38, 38,
198
+ 38, 38, 38, 38, 38, 38, 38, 38,
199
+ 1, 1, 1, 38, 38, 38, 38, 38,
200
+ 38, 38, 38, 38, 38, 38, 38, 38,
201
+ 38, 38, 38, 38, 38, 38, 38, 38,
202
+ 38, 38, 38, 38, 38, 38, 38, 38,
203
+ 38, 38, 38, 38, 1, 40, 40, 40,
204
+ 40, 40, 40, 40, 40, 40, 1, 40,
205
+ 40, 41, 40, 40, 40, 40, 40, 40,
206
+ 40, 40, 40, 40, 40, 40, 40, 40,
207
+ 40, 40, 40, 40, 40, 40, 40, 40,
208
+ 40, 40, 40, 40, 42, 43, 40, 40,
209
+ 40, 40, 40, 40, 40, 40, 40, 40,
210
+ 40, 40, 40, 40, 40, 40, 40, 40,
211
+ 40, 40, 40, 40, 40, 40, 40, 40,
212
+ 40, 40, 40, 40, 40, 40, 40, 40,
213
+ 40, 40, 40, 40, 40, 40, 40, 40,
214
+ 40, 40, 40, 40, 40, 40, 40, 40,
215
+ 44, 40, 40, 40, 40, 40, 40, 40,
216
+ 40, 40, 40, 40, 40, 40, 40, 40,
217
+ 40, 40, 40, 40, 40, 40, 40, 40,
218
+ 40, 40, 40, 40, 40, 40, 40, 40,
219
+ 40, 40, 40, 40, 1, 45, 45, 45,
220
+ 45, 45, 45, 45, 45, 45, 1, 45,
221
+ 45, 46, 45, 45, 45, 45, 45, 45,
222
+ 45, 45, 45, 45, 45, 45, 45, 45,
223
+ 45, 45, 45, 45, 45, 45, 45, 45,
224
+ 45, 45, 45, 45, 47, 48, 45, 45,
225
+ 45, 45, 45, 45, 45, 45, 45, 45,
226
+ 45, 45, 45, 45, 45, 45, 45, 45,
227
+ 45, 45, 45, 45, 45, 45, 45, 45,
228
+ 45, 45, 45, 45, 45, 45, 45, 45,
229
+ 45, 45, 45, 45, 45, 45, 45, 45,
230
+ 45, 45, 45, 45, 45, 45, 45, 45,
231
+ 49, 45, 45, 45, 45, 45, 45, 45,
232
+ 45, 45, 45, 45, 45, 45, 45, 45,
233
+ 45, 45, 45, 45, 45, 45, 45, 45,
234
+ 45, 45, 45, 45, 45, 45, 45, 45,
235
+ 45, 45, 45, 45, 1, 50, 1, 45,
236
+ 1, 1, 1, 1, 1, 1, 1, 1,
237
+ 1, 1, 1, 1, 1, 1, 1, 1,
238
+ 1, 1, 1, 1, 1, 1, 45, 1,
239
+ 1, 1, 1, 1, 1, 1, 1, 1,
240
+ 1, 1, 1, 1, 1, 1, 1, 1,
241
+ 1, 1, 1, 1, 1, 1, 1, 1,
242
+ 1, 1, 1, 1, 1, 1, 1, 1,
243
+ 1, 1, 1, 1, 1, 1, 1, 1,
244
+ 1, 1, 1, 1, 1, 1, 1, 1,
245
+ 1, 1, 1, 1, 1, 1, 1, 1,
246
+ 1, 1, 1, 1, 1, 1, 1, 1,
247
+ 1, 1, 1, 1, 1, 1, 1, 1,
248
+ 1, 1, 1, 1, 1, 1, 1, 1,
249
+ 1, 1, 1, 1, 1, 1, 1, 1,
250
+ 1, 1, 1, 1, 1, 1, 1, 1,
251
+ 1, 1, 1, 1, 1, 1, 1, 1,
252
+ 1, 1, 1, 1, 1, 1, 1, 1,
253
+ 1, 1, 1, 1, 1, 1, 1, 1,
254
+ 1, 1, 1, 1, 1, 1, 1, 1,
255
+ 45, 51, 51, 51, 51, 51, 51, 51,
256
+ 1, 1, 51, 51, 51, 51, 51, 1,
257
+ 51, 51, 51, 51, 51, 51, 51, 51,
258
+ 51, 51, 1, 52, 1, 1, 1, 1,
259
+ 1, 51, 51, 51, 51, 51, 51, 51,
260
+ 51, 51, 51, 51, 51, 51, 51, 51,
261
+ 51, 51, 51, 51, 51, 51, 51, 51,
262
+ 51, 51, 51, 1, 1, 1, 51, 51,
263
+ 51, 51, 51, 51, 51, 51, 51, 51,
264
+ 51, 51, 51, 51, 51, 51, 51, 51,
265
+ 51, 51, 51, 51, 51, 51, 51, 51,
266
+ 51, 51, 51, 51, 51, 51, 51, 1,
267
+ 53, 1, 1, 1, 54, 1, 1, 1,
268
+ 1, 1, 1, 1, 1, 1, 1, 1,
269
+ 1, 1, 1, 1, 1, 1, 1, 53,
270
+ 1, 1, 1, 1, 1, 1, 1, 55,
271
+ 1, 1, 1, 1, 1, 1, 1, 1,
272
+ 1, 1, 1, 1, 1, 1, 1, 1,
273
+ 1, 1, 56, 1, 57, 1, 1, 1,
274
+ 58, 1, 1, 1, 1, 1, 1, 1,
275
+ 1, 1, 1, 1, 1, 1, 1, 1,
276
+ 1, 1, 1, 57, 1, 1, 1, 1,
277
+ 1, 1, 1, 59, 1, 1, 1, 1,
278
+ 1, 1, 1, 1, 1, 1, 1, 1,
279
+ 1, 1, 1, 1, 1, 1, 60, 1,
280
+ 61, 1, 1, 1, 62, 1, 1, 1,
281
+ 1, 1, 1, 1, 1, 1, 1, 1,
282
+ 1, 1, 1, 1, 1, 1, 1, 61,
283
+ 63, 1, 63, 63, 63, 63, 63, 64,
284
+ 1, 63, 63, 63, 63, 63, 1, 63,
285
+ 63, 63, 63, 63, 63, 63, 63, 63,
286
+ 63, 1, 56, 1, 63, 1, 1, 1,
287
+ 63, 63, 63, 63, 63, 63, 63, 63,
288
+ 63, 63, 63, 63, 63, 63, 63, 63,
289
+ 63, 63, 63, 63, 63, 63, 63, 63,
290
+ 63, 63, 1, 1, 1, 63, 63, 63,
291
+ 63, 63, 63, 63, 63, 63, 63, 63,
292
+ 63, 63, 63, 63, 63, 63, 63, 63,
293
+ 63, 63, 63, 63, 63, 63, 63, 63,
294
+ 63, 63, 63, 63, 63, 63, 1, 35,
295
+ 1, 1, 1, 65, 1, 1, 1, 1,
296
+ 1, 1, 1, 1, 1, 1, 1, 1,
297
+ 1, 1, 1, 1, 1, 1, 35, 1,
298
+ 1, 1, 1, 1, 1, 1, 66, 1,
299
+ 1, 1, 1, 1, 1, 1, 1, 1,
300
+ 1, 1, 1, 1, 1, 1, 1, 1,
301
+ 1, 2, 1, 67, 1, 1, 1, 68,
302
+ 1, 1, 1, 1, 1, 1, 1, 1,
303
+ 1, 1, 1, 1, 1, 1, 1, 1,
304
+ 1, 1, 67, 1, 1, 1, 1, 1,
305
+ 1, 1, 69, 1, 1, 1, 1, 1,
306
+ 1, 1, 1, 1, 1, 1, 1, 1,
307
+ 1, 1, 1, 1, 1, 36, 1, 1,
308
+ 0
309
+ ]
310
+
311
+ class << self
312
+ attr_accessor :_trans_targs
313
+ private :_trans_targs, :_trans_targs=
314
+ end
315
+ self._trans_targs = [
316
+ 26, 0, 2, 3, 5, 20, 4, 5,
317
+ 6, 7, 8, 29, 10, 17, 7, 8,
318
+ 10, 17, 9, 11, 12, 27, 16, 11,
319
+ 12, 27, 16, 13, 15, 27, 7, 8,
320
+ 10, 17, 19, 30, 2, 3, 5, 20,
321
+ 22, 23, 22, 32, 25, 22, 23, 22,
322
+ 32, 25, 24, 26, 2, 27, 14, 28,
323
+ 2, 27, 14, 28, 2, 30, 18, 29,
324
+ 31, 18, 31, 30, 18, 31
325
+ ]
326
+
327
+ class << self
328
+ attr_accessor :_trans_actions
329
+ private :_trans_actions, :_trans_actions=
330
+ end
331
+ self._trans_actions = [
332
+ 1, 0, 0, 0, 2, 3, 0, 0,
333
+ 4, 5, 5, 5, 5, 6, 0, 0,
334
+ 0, 3, 0, 7, 7, 8, 7, 0,
335
+ 0, 9, 0, 0, 0, 0, 10, 10,
336
+ 10, 11, 0, 0, 10, 10, 12, 11,
337
+ 13, 13, 14, 15, 13, 0, 0, 3,
338
+ 16, 0, 0, 0, 17, 18, 18, 19,
339
+ 18, 20, 20, 21, 20, 18, 18, 0,
340
+ 22, 0, 3, 10, 10, 11
341
+ ]
18
342
 
343
+ class << self
344
+ attr_accessor :_eof_actions
345
+ private :_eof_actions, :_eof_actions=
346
+ end
347
+ self._eof_actions = [
348
+ 0, 0, 0, 0, 0, 0, 0, 0,
349
+ 0, 0, 0, 0, 0, 0, 0, 0,
350
+ 0, 0, 0, 0, 0, 0, 0, 0,
351
+ 0, 0, 17, 18, 20, 18, 0, 10,
352
+ 0
353
+ ]
354
+
355
+ class << self
356
+ attr_accessor :start
357
+ end
358
+ self.start = 1;
359
+ class << self
360
+ attr_accessor :first_final
361
+ end
362
+ self.first_final = 26;
363
+ class << self
364
+ attr_accessor :error
365
+ end
366
+ self.error = 0;
367
+
368
+ class << self
369
+ attr_accessor :en_comment_tail
370
+ end
371
+ self.en_comment_tail = 21;
372
+ class << self
373
+ attr_accessor :en_main
374
+ end
375
+ self.en_main = 1;
376
+
377
+
378
+
379
+ def self.parse(data)
380
+ content_disposition = ContentDispositionStruct.new('', [])
381
+ return content_disposition if Mail::Utilities.blank?(data)
382
+
383
+ # Parser state
19
384
  disp_type_s = param_attr_s = param_attr = qstr_s = qstr = param_val_s = nil
20
- actions.each_slice(2) do |action_id, p|
21
- action = Mail::Parsers::Ragel::ACTIONS[action_id]
22
- case action
23
-
24
- # Disposition Type
25
- when :disp_type_s then disp_type_s = p
26
- when :disp_type_e
27
- content_disposition.disposition_type = s[disp_type_s..(p-1)].downcase
28
-
29
- # Parameter Attribute
30
- when :param_attr_s then param_attr_s = p
31
- when :param_attr_e then param_attr = s[param_attr_s..(p-1)]
32
-
33
- # Quoted String.
34
- when :qstr_s then qstr_s = p
35
- when :qstr_e then qstr = s[qstr_s..(p-1)]
36
-
37
- # Parameter Value
38
- when :param_val_s then param_val_s = p
39
- when :param_val_e
40
- if param_attr.nil?
41
- raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, s, "no attribute for value")
42
- end
43
-
44
- # Use quoted string value if one exists, otherwise use parameter value
45
- if qstr
46
- value = qstr
47
- else
48
- value = s[param_val_s..(p-1)]
49
- end
50
-
51
- content_disposition.parameters << { param_attr => value }
52
- param_attr = nil
53
- qstr = nil
54
-
55
- else
56
- raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, s, "Failed to process unknown action: #{action}")
57
- end
58
- end
59
385
 
60
- content_disposition
386
+ # 5.1 Variables Used by Ragel
387
+ p = 0
388
+ eof = pe = data.length
389
+ stack = []
390
+
391
+
392
+ begin
393
+ p ||= 0
394
+ pe ||= data.length
395
+ cs = start
396
+ top = 0
397
+ end
398
+
399
+
400
+ begin
401
+ testEof = false
402
+ _slen, _trans, _keys, _inds, _acts, _nacts = nil
403
+ _goto_level = 0
404
+ _resume = 10
405
+ _eof_trans = 15
406
+ _again = 20
407
+ _test_eof = 30
408
+ _out = 40
409
+ while true
410
+ if _goto_level <= 0
411
+ if p == pe
412
+ _goto_level = _test_eof
413
+ next
414
+ end
415
+ if cs == 0
416
+ _goto_level = _out
417
+ next
418
+ end
419
+ end
420
+ if _goto_level <= _resume
421
+ _keys = cs << 1
422
+ _inds = _index_offsets[cs]
423
+ _slen = _key_spans[cs]
424
+ _wide = data[p].ord
425
+ _trans = if ( _slen > 0 &&
426
+ _trans_keys[_keys] <= _wide &&
427
+ _wide <= _trans_keys[_keys + 1]
428
+ ) then
429
+ _indicies[ _inds + _wide - _trans_keys[_keys] ]
430
+ else
431
+ _indicies[ _inds + _slen ]
432
+ end
433
+ cs = _trans_targs[_trans]
434
+ if _trans_actions[_trans] != 0
435
+ case _trans_actions[_trans]
436
+ when 1 then
437
+ begin
438
+ disp_type_s = p end
439
+ when 17 then
440
+ begin
441
+ content_disposition.disposition_type = data[disp_type_s..(p-1)].downcase end
442
+ when 2 then
443
+ begin
444
+ param_attr_s = p end
445
+ when 4 then
446
+ begin
447
+ param_attr = data[param_attr_s..(p-1)] end
448
+ when 7 then
449
+ begin
450
+ qstr_s = p end
451
+ when 9 then
452
+ begin
453
+ qstr = data[qstr_s..(p-1)] end
454
+ when 5 then
455
+ begin
456
+ param_val_s = p end
457
+ when 18 then
458
+ begin
459
+
460
+ if param_attr.nil?
461
+ raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, data, "no attribute for value")
462
+ end
463
+
464
+ # Use quoted string value if one exists, otherwise use parameter value
465
+ value = qstr || data[param_val_s..(p-1)]
466
+
467
+ content_disposition.parameters << { param_attr => value }
468
+ param_attr = nil
469
+ qstr = nil
470
+ end
471
+ when 10 then
472
+ begin
473
+ end
474
+ when 13 then
475
+ begin
476
+ end
477
+ when 3 then
478
+ begin
479
+ begin
480
+ stack[top] = cs
481
+ top+= 1
482
+ cs = 21
483
+ _goto_level = _again
484
+ next
485
+ end
486
+ end
487
+ when 16 then
488
+ begin
489
+ begin
490
+ top -= 1
491
+ cs = stack[top]
492
+ _goto_level = _again
493
+ next
494
+ end
495
+ end
496
+ when 8 then
497
+ begin
498
+ qstr_s = p end
499
+ begin
500
+ qstr = data[qstr_s..(p-1)] end
501
+ when 6 then
502
+ begin
503
+ param_val_s = p end
504
+ begin
505
+ begin
506
+ stack[top] = cs
507
+ top+= 1
508
+ cs = 21
509
+ _goto_level = _again
510
+ next
511
+ end
512
+ end
513
+ when 22 then
514
+ begin
515
+
516
+ if param_attr.nil?
517
+ raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, data, "no attribute for value")
518
+ end
519
+
520
+ # Use quoted string value if one exists, otherwise use parameter value
521
+ value = qstr || data[param_val_s..(p-1)]
522
+
523
+ content_disposition.parameters << { param_attr => value }
524
+ param_attr = nil
525
+ qstr = nil
526
+ end
527
+ begin
528
+ begin
529
+ stack[top] = cs
530
+ top+= 1
531
+ cs = 21
532
+ _goto_level = _again
533
+ next
534
+ end
535
+ end
536
+ when 12 then
537
+ begin
538
+ end
539
+ begin
540
+ param_attr_s = p end
541
+ when 20 then
542
+ begin
543
+ end
544
+ begin
545
+
546
+ if param_attr.nil?
547
+ raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, data, "no attribute for value")
548
+ end
549
+
550
+ # Use quoted string value if one exists, otherwise use parameter value
551
+ value = qstr || data[param_val_s..(p-1)]
552
+
553
+ content_disposition.parameters << { param_attr => value }
554
+ param_attr = nil
555
+ qstr = nil
556
+ end
557
+ when 11 then
558
+ begin
559
+ end
560
+ begin
561
+ begin
562
+ stack[top] = cs
563
+ top+= 1
564
+ cs = 21
565
+ _goto_level = _again
566
+ next
567
+ end
568
+ end
569
+ when 14 then
570
+ begin
571
+ end
572
+ begin
573
+ begin
574
+ stack[top] = cs
575
+ top+= 1
576
+ cs = 21
577
+ _goto_level = _again
578
+ next
579
+ end
580
+ end
581
+ when 15 then
582
+ begin
583
+ end
584
+ begin
585
+ begin
586
+ top -= 1
587
+ cs = stack[top]
588
+ _goto_level = _again
589
+ next
590
+ end
591
+ end
592
+ when 19 then
593
+ begin
594
+ begin
595
+ stack[top] = cs
596
+ top+= 1
597
+ cs = 21
598
+ _goto_level = _again
599
+ next
600
+ end
601
+ end
602
+ begin
603
+
604
+ if param_attr.nil?
605
+ raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, data, "no attribute for value")
606
+ end
607
+
608
+ # Use quoted string value if one exists, otherwise use parameter value
609
+ value = qstr || data[param_val_s..(p-1)]
610
+
611
+ content_disposition.parameters << { param_attr => value }
612
+ param_attr = nil
613
+ qstr = nil
614
+ end
615
+ when 21 then
616
+ begin
617
+ end
618
+ begin
619
+ begin
620
+ stack[top] = cs
621
+ top+= 1
622
+ cs = 21
623
+ _goto_level = _again
624
+ next
625
+ end
626
+ end
627
+ begin
628
+
629
+ if param_attr.nil?
630
+ raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, data, "no attribute for value")
61
631
  end
62
632
 
63
- private
64
- def cleaned(string)
65
- string =~ /(.+);\s*$/ ? $1 : string
633
+ # Use quoted string value if one exists, otherwise use parameter value
634
+ value = qstr || data[param_val_s..(p-1)]
635
+
636
+ content_disposition.parameters << { param_attr => value }
637
+ param_attr = nil
638
+ qstr = nil
639
+ end
640
+ end
641
+ end
642
+ end
643
+ if _goto_level <= _again
644
+ if cs == 0
645
+ _goto_level = _out
646
+ next
647
+ end
648
+ p += 1
649
+ if p != pe
650
+ _goto_level = _resume
651
+ next
652
+ end
653
+ end
654
+ if _goto_level <= _test_eof
655
+ if p == eof
656
+ case _eof_actions[cs]
657
+ when 17 then
658
+ begin
659
+ content_disposition.disposition_type = data[disp_type_s..(p-1)].downcase end
660
+ when 18 then
661
+ begin
662
+
663
+ if param_attr.nil?
664
+ raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, data, "no attribute for value")
665
+ end
666
+
667
+ # Use quoted string value if one exists, otherwise use parameter value
668
+ value = qstr || data[param_val_s..(p-1)]
669
+
670
+ content_disposition.parameters << { param_attr => value }
671
+ param_attr = nil
672
+ qstr = nil
673
+ end
674
+ when 10 then
675
+ begin
676
+ end
677
+ when 20 then
678
+ begin
679
+ end
680
+ begin
681
+
682
+ if param_attr.nil?
683
+ raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, data, "no attribute for value")
684
+ end
685
+
686
+ # Use quoted string value if one exists, otherwise use parameter value
687
+ value = qstr || data[param_val_s..(p-1)]
688
+
689
+ content_disposition.parameters << { param_attr => value }
690
+ param_attr = nil
691
+ qstr = nil
692
+ end
693
+ end
694
+ end
695
+
696
+ end
697
+ if _goto_level <= _out
698
+ break
699
+ end
700
+ end
701
+ end
702
+
703
+
704
+ if p != eof || cs < 26
705
+ raise Mail::Field::ParseError.new(Mail::ContentDispositionElement, data, "Only able to parse up to #{data[0..p]}")
706
+ end
707
+
708
+ content_disposition
66
709
  end
67
710
  end
68
711
  end
OSZAR »