mail 2.5.5 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.rdoc +8 -9
  3. data/CONTRIBUTING.md +13 -0
  4. data/Dependencies.txt +0 -1
  5. data/Gemfile +7 -24
  6. data/README.md +36 -15
  7. data/Rakefile +10 -2
  8. data/VERSION +4 -0
  9. data/lib/mail.rb +1 -1
  10. data/lib/mail/body.rb +2 -2
  11. data/lib/mail/check_delivery_params.rb +10 -47
  12. data/lib/mail/core_extensions/string.rb +12 -2
  13. data/lib/mail/elements/address.rb +38 -82
  14. data/lib/mail/elements/address_list.rb +19 -42
  15. data/lib/mail/elements/content_disposition_element.rb +3 -7
  16. data/lib/mail/elements/content_location_element.rb +2 -6
  17. data/lib/mail/elements/content_transfer_encoding_element.rb +3 -10
  18. data/lib/mail/elements/content_type_element.rb +4 -8
  19. data/lib/mail/elements/date_time_element.rb +3 -7
  20. data/lib/mail/elements/envelope_from_element.rb +3 -11
  21. data/lib/mail/elements/message_ids_element.rb +1 -6
  22. data/lib/mail/elements/mime_version_element.rb +3 -7
  23. data/lib/mail/elements/phrase_list.rb +2 -7
  24. data/lib/mail/elements/received_element.rb +3 -7
  25. data/lib/mail/encodings.rb +0 -1
  26. data/lib/mail/envelope.rb +0 -5
  27. data/lib/mail/field.rb +53 -17
  28. data/lib/mail/field_list.rb +18 -18
  29. data/lib/mail/fields/common/common_address.rb +15 -20
  30. data/lib/mail/fields/common/common_date.rb +0 -7
  31. data/lib/mail/fields/common/common_field.rb +1 -1
  32. data/lib/mail/fields/content_transfer_encoding_field.rb +0 -6
  33. data/lib/mail/fields/resent_sender_field.rb +1 -1
  34. data/lib/mail/fields/sender_field.rb +1 -1
  35. data/lib/mail/fields/unstructured_field.rb +7 -1
  36. data/lib/mail/header.rb +8 -22
  37. data/lib/mail/mail.rb +12 -0
  38. data/lib/mail/matchers/has_sent_mail.rb +34 -1
  39. data/lib/mail/message.rb +18 -11
  40. data/lib/mail/multibyte/unicode.rb +1 -1
  41. data/lib/mail/network/delivery_methods/exim.rb +10 -6
  42. data/lib/mail/network/delivery_methods/file_delivery.rb +8 -4
  43. data/lib/mail/network/delivery_methods/sendmail.rb +7 -9
  44. data/lib/mail/network/delivery_methods/smtp.rb +5 -2
  45. data/lib/mail/network/delivery_methods/smtp_connection.rb +6 -2
  46. data/lib/mail/network/delivery_methods/test_mailer.rb +8 -5
  47. data/lib/mail/network/retriever_methods/imap.rb +18 -13
  48. data/lib/mail/parsers.rb +26 -0
  49. data/lib/mail/parsers/address_lists_parser.rb +132 -0
  50. data/lib/mail/parsers/content_disposition_parser.rb +67 -0
  51. data/lib/mail/parsers/content_location_parser.rb +35 -0
  52. data/lib/mail/parsers/content_transfer_encoding_parser.rb +33 -0
  53. data/lib/mail/parsers/content_type_parser.rb +64 -0
  54. data/lib/mail/parsers/date_time_parser.rb +36 -0
  55. data/lib/mail/parsers/envelope_from_parser.rb +45 -0
  56. data/lib/mail/parsers/message_ids_parser.rb +39 -0
  57. data/lib/mail/parsers/mime_version_parser.rb +41 -0
  58. data/lib/mail/parsers/phrase_lists_parser.rb +33 -0
  59. data/lib/mail/parsers/ragel.rb +17 -0
  60. data/lib/mail/parsers/ragel/common.rl +184 -0
  61. data/lib/mail/parsers/ragel/date_time.rl +30 -0
  62. data/lib/mail/parsers/ragel/parser_info.rb +61 -0
  63. data/lib/mail/parsers/ragel/ruby.rb +29 -0
  64. data/lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb +14864 -0
  65. data/lib/mail/parsers/ragel/ruby/machines/address_lists_machine.rb.rl +37 -0
  66. data/lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb +751 -0
  67. data/lib/mail/parsers/ragel/ruby/machines/content_disposition_machine.rb.rl +37 -0
  68. data/lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb +614 -0
  69. data/lib/mail/parsers/ragel/ruby/machines/content_location_machine.rb.rl +37 -0
  70. data/lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb +447 -0
  71. data/lib/mail/parsers/ragel/ruby/machines/content_transfer_encoding_machine.rb.rl +37 -0
  72. data/lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb +825 -0
  73. data/lib/mail/parsers/ragel/ruby/machines/content_type_machine.rb.rl +37 -0
  74. data/lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb +817 -0
  75. data/lib/mail/parsers/ragel/ruby/machines/date_time_machine.rb.rl +37 -0
  76. data/lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb +2129 -0
  77. data/lib/mail/parsers/ragel/ruby/machines/envelope_from_machine.rb.rl +37 -0
  78. data/lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb +1570 -0
  79. data/lib/mail/parsers/ragel/ruby/machines/message_ids_machine.rb.rl +37 -0
  80. data/lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb +440 -0
  81. data/lib/mail/parsers/ragel/ruby/machines/mime_version_machine.rb.rl +37 -0
  82. data/lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb +564 -0
  83. data/lib/mail/parsers/ragel/ruby/machines/phrase_lists_machine.rb.rl +37 -0
  84. data/lib/mail/parsers/ragel/ruby/machines/rb_actions.rl +51 -0
  85. data/lib/mail/parsers/ragel/ruby/machines/received_machine.rb +5144 -0
  86. data/lib/mail/parsers/ragel/ruby/machines/received_machine.rb.rl +37 -0
  87. data/lib/mail/parsers/ragel/ruby/parser.rb.rl.erb +37 -0
  88. data/lib/mail/parsers/received_parser.rb +47 -0
  89. data/lib/mail/parts_list.rb +4 -2
  90. data/lib/mail/patterns.rb +3 -1
  91. data/lib/mail/utilities.rb +3 -1
  92. data/lib/mail/version.rb +1 -1
  93. data/lib/mail/version_specific/ruby_1_8.rb +1 -1
  94. data/lib/mail/version_specific/ruby_1_9.rb +13 -1
  95. metadata +55 -51
  96. data/lib/VERSION +0 -4
  97. data/lib/load_parsers.rb +0 -35
  98. data/lib/mail/parsers/address_lists.rb +0 -64
  99. data/lib/mail/parsers/address_lists.treetop +0 -19
  100. data/lib/mail/parsers/content_disposition.rb +0 -535
  101. data/lib/mail/parsers/content_disposition.treetop +0 -46
  102. data/lib/mail/parsers/content_location.rb +0 -139
  103. data/lib/mail/parsers/content_location.treetop +0 -20
  104. data/lib/mail/parsers/content_transfer_encoding.rb +0 -201
  105. data/lib/mail/parsers/content_transfer_encoding.treetop +0 -18
  106. data/lib/mail/parsers/content_type.rb +0 -971
  107. data/lib/mail/parsers/content_type.treetop +0 -68
  108. data/lib/mail/parsers/date_time.rb +0 -114
  109. data/lib/mail/parsers/date_time.treetop +0 -11
  110. data/lib/mail/parsers/envelope_from.rb +0 -194
  111. data/lib/mail/parsers/envelope_from.treetop +0 -32
  112. data/lib/mail/parsers/message_ids.rb +0 -45
  113. data/lib/mail/parsers/message_ids.treetop +0 -15
  114. data/lib/mail/parsers/mime_version.rb +0 -144
  115. data/lib/mail/parsers/mime_version.treetop +0 -19
  116. data/lib/mail/parsers/phrase_lists.rb +0 -45
  117. data/lib/mail/parsers/phrase_lists.treetop +0 -15
  118. data/lib/mail/parsers/received.rb +0 -71
  119. data/lib/mail/parsers/received.treetop +0 -11
  120. data/lib/mail/parsers/rfc2045.rb +0 -421
  121. data/lib/mail/parsers/rfc2045.treetop +0 -35
  122. data/lib/mail/parsers/rfc2822.rb +0 -5397
  123. data/lib/mail/parsers/rfc2822.treetop +0 -408
  124. data/lib/mail/parsers/rfc2822_obsolete.rb +0 -3768
  125. data/lib/mail/parsers/rfc2822_obsolete.treetop +0 -241
  126. data/lib/tasks/corpus.rake +0 -125
  127. data/lib/tasks/treetop.rake +0 -10
@@ -1,68 +0,0 @@
1
- module Mail
2
- grammar ContentType
3
-
4
- include RFC2822
5
- include RFC2045
6
-
7
- rule content_type
8
- main_type "/" sub_type param_hashes:(CFWS ";"* parameter CFWS)* {
9
- def parameters
10
- param_hashes.elements.map do |param|
11
- param.parameter.param_hash
12
- end
13
- end
14
- }
15
- end
16
-
17
- rule main_type
18
- discrete_type / composite_type
19
- end
20
-
21
- # This matches in a case insensitive way:
22
- #
23
- # rule discrete_type
24
- # "text" / "image" / "audio" / "video" / "application" / extension_token
25
- # end
26
- rule discrete_type
27
- [tT] [eE] [xX] [tT] / [iI] [mM] [aA] [gG] [eE] / [aA] [uU] [dD] [iI] [oO] / [vV] [iI] [dD] [eE] [oO] / [aA] [pP] [pP] [lL] [iI] [cC] [aA] [tT] [iI] [oO] [nN] / extension_token
28
- end
29
-
30
- # This matches in a case insensitive way:
31
- #
32
- # rule composite_type
33
- # "message" / "multipart" / extension_token
34
- # end
35
- rule composite_type
36
- [mM] [eE] [sS] [sS] [aA] [gG] [eE] / [mM] [uU] [lL] [tT] [iI] [pP] [aA] [rR] [tT] / extension_token
37
- end
38
-
39
- rule extension_token
40
- ietf_token / custom_x_token
41
- end
42
-
43
- rule sub_type
44
- extension_token / iana_token
45
- end
46
-
47
- rule parameter
48
- CFWS? attr:attribute "=" val:value CFWS? {
49
- def param_hash
50
- {attr.text_value => val.text_value}
51
- end
52
- }
53
- end
54
-
55
- rule attribute
56
- token+
57
- end
58
-
59
- rule value
60
- quoted_string {
61
- def text_value
62
- quoted_content.text_value
63
- end
64
- } / (token / [\x3d])+
65
- end
66
-
67
- end
68
- end
@@ -1,114 +0,0 @@
1
- # Autogenerated from a Treetop grammar. Edits may be lost.
2
-
3
-
4
- module Mail
5
- module DateTime
6
- include Treetop::Runtime
7
-
8
- def root
9
- @root ||= :primary
10
- end
11
-
12
- include RFC2822
13
-
14
- module Primary0
15
- def day_of_week
16
- elements[0]
17
- end
18
-
19
- end
20
-
21
- module Primary1
22
- def date
23
- elements[1]
24
- end
25
-
26
- def FWS
27
- elements[2]
28
- end
29
-
30
- def time
31
- elements[3]
32
- end
33
-
34
- end
35
-
36
- def _nt_primary
37
- start_index = index
38
- if node_cache[:primary].has_key?(index)
39
- cached = node_cache[:primary][index]
40
- if cached
41
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
42
- @index = cached.interval.end
43
- end
44
- return cached
45
- end
46
-
47
- i0, s0 = index, []
48
- i2, s2 = index, []
49
- r3 = _nt_day_of_week
50
- s2 << r3
51
- if r3
52
- if has_terminal?(",", false, index)
53
- r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
54
- @index += 1
55
- else
56
- terminal_parse_failure(",")
57
- r4 = nil
58
- end
59
- s2 << r4
60
- end
61
- if s2.last
62
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
63
- r2.extend(Primary0)
64
- else
65
- @index = i2
66
- r2 = nil
67
- end
68
- if r2
69
- r1 = r2
70
- else
71
- r1 = instantiate_node(SyntaxNode,input, index...index)
72
- end
73
- s0 << r1
74
- if r1
75
- r5 = _nt_date
76
- s0 << r5
77
- if r5
78
- r6 = _nt_FWS
79
- s0 << r6
80
- if r6
81
- r7 = _nt_time
82
- s0 << r7
83
- if r7
84
- r9 = _nt_CFWS
85
- if r9
86
- r8 = r9
87
- else
88
- r8 = instantiate_node(SyntaxNode,input, index...index)
89
- end
90
- s0 << r8
91
- end
92
- end
93
- end
94
- end
95
- if s0.last
96
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
97
- r0.extend(Primary1)
98
- else
99
- @index = i0
100
- r0 = nil
101
- end
102
-
103
- node_cache[:primary][start_index] = r0
104
-
105
- r0
106
- end
107
-
108
- end
109
-
110
- class DateTimeParser < Treetop::Runtime::CompiledParser
111
- include DateTime
112
- end
113
-
114
- end
@@ -1,11 +0,0 @@
1
- module Mail
2
- grammar DateTime
3
-
4
- include RFC2822
5
-
6
- rule primary
7
- ( day_of_week ",")? date FWS time CFWS?
8
- end
9
-
10
- end
11
- end
@@ -1,194 +0,0 @@
1
- # Autogenerated from a Treetop grammar. Edits may be lost.
2
-
3
-
4
- module Mail
5
- module EnvelopeFrom
6
- include Treetop::Runtime
7
-
8
- def root
9
- @root ||= :primary
10
- end
11
-
12
- include RFC2822
13
-
14
- module Primary0
15
- def addr_spec
16
- elements[0]
17
- end
18
-
19
- def ctime_date
20
- elements[1]
21
- end
22
- end
23
-
24
- def _nt_primary
25
- start_index = index
26
- if node_cache[:primary].has_key?(index)
27
- cached = node_cache[:primary][index]
28
- if cached
29
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
30
- @index = cached.interval.end
31
- end
32
- return cached
33
- end
34
-
35
- i0, s0 = index, []
36
- r1 = _nt_addr_spec
37
- s0 << r1
38
- if r1
39
- r2 = _nt_ctime_date
40
- s0 << r2
41
- end
42
- if s0.last
43
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
44
- r0.extend(Primary0)
45
- else
46
- @index = i0
47
- r0 = nil
48
- end
49
-
50
- node_cache[:primary][start_index] = r0
51
-
52
- r0
53
- end
54
-
55
- module CtimeDate0
56
- def day_name
57
- elements[0]
58
- end
59
-
60
- def month_name
61
- elements[2]
62
- end
63
-
64
- def day
65
- elements[4]
66
- end
67
-
68
- def time_of_day
69
- elements[6]
70
- end
71
-
72
- def year
73
- elements[8]
74
- end
75
- end
76
-
77
- def _nt_ctime_date
78
- start_index = index
79
- if node_cache[:ctime_date].has_key?(index)
80
- cached = node_cache[:ctime_date][index]
81
- if cached
82
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
83
- @index = cached.interval.end
84
- end
85
- return cached
86
- end
87
-
88
- i0, s0 = index, []
89
- r1 = _nt_day_name
90
- s0 << r1
91
- if r1
92
- s2, i2 = [], index
93
- loop do
94
- if has_terminal?(" ", false, index)
95
- r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
96
- @index += 1
97
- else
98
- terminal_parse_failure(" ")
99
- r3 = nil
100
- end
101
- if r3
102
- s2 << r3
103
- else
104
- break
105
- end
106
- end
107
- if s2.empty?
108
- @index = i2
109
- r2 = nil
110
- else
111
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
112
- end
113
- s0 << r2
114
- if r2
115
- r4 = _nt_month_name
116
- s0 << r4
117
- if r4
118
- s5, i5 = [], index
119
- loop do
120
- if has_terminal?(" ", false, index)
121
- r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
122
- @index += 1
123
- else
124
- terminal_parse_failure(" ")
125
- r6 = nil
126
- end
127
- if r6
128
- s5 << r6
129
- else
130
- break
131
- end
132
- end
133
- if s5.empty?
134
- @index = i5
135
- r5 = nil
136
- else
137
- r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
138
- end
139
- s0 << r5
140
- if r5
141
- r7 = _nt_day
142
- s0 << r7
143
- if r7
144
- if has_terminal?(" ", false, index)
145
- r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
146
- @index += 1
147
- else
148
- terminal_parse_failure(" ")
149
- r8 = nil
150
- end
151
- s0 << r8
152
- if r8
153
- r9 = _nt_time_of_day
154
- s0 << r9
155
- if r9
156
- if has_terminal?(" ", false, index)
157
- r10 = instantiate_node(SyntaxNode,input, index...(index + 1))
158
- @index += 1
159
- else
160
- terminal_parse_failure(" ")
161
- r10 = nil
162
- end
163
- s0 << r10
164
- if r10
165
- r11 = _nt_year
166
- s0 << r11
167
- end
168
- end
169
- end
170
- end
171
- end
172
- end
173
- end
174
- end
175
- if s0.last
176
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
177
- r0.extend(CtimeDate0)
178
- else
179
- @index = i0
180
- r0 = nil
181
- end
182
-
183
- node_cache[:ctime_date][start_index] = r0
184
-
185
- r0
186
- end
187
-
188
- end
189
-
190
- class EnvelopeFromParser < Treetop::Runtime::CompiledParser
191
- include EnvelopeFrom
192
- end
193
-
194
- end
@@ -1,32 +0,0 @@
1
- module Mail
2
- grammar EnvelopeFrom
3
-
4
- include RFC2822
5
-
6
- # The exact character sequence of "From";
7
- #
8
- # a single Space character (0x20);
9
- #
10
- # the email address of the message sender (as obtained from the
11
- # message envelope or other authoritative source), conformant
12
- # with the "addr-spec" syntax from RFC 2822;
13
- #
14
- # a single Space character;
15
- #
16
- # a timestamp indicating the UTC date and time when the message
17
- # was originally received, conformant with the syntax of the
18
- # traditional UNIX 'ctime' output sans timezone (note that the
19
- # use of UTC precludes the need for a timezone indicator);
20
- # Thu Nov 24 18:22:48 1986
21
- #
22
- # an end-of-line marker.
23
- rule primary
24
- addr_spec ctime_date
25
- end
26
-
27
- rule ctime_date
28
- day_name " "+ month_name " "+ day " " time_of_day " " year
29
- end
30
-
31
- end
32
- end
@@ -1,45 +0,0 @@
1
- # Autogenerated from a Treetop grammar. Edits may be lost.
2
-
3
-
4
- module Mail
5
- module MessageIds
6
- include Treetop::Runtime
7
-
8
- def root
9
- @root ||= :primary
10
- end
11
-
12
- include RFC2822
13
-
14
- module Primary0
15
- def message_ids
16
- [first_msg_id] + other_msg_ids.elements.map { |o| o.msg_id_value }
17
- end
18
- end
19
-
20
- def _nt_primary
21
- start_index = index
22
- if node_cache[:primary].has_key?(index)
23
- cached = node_cache[:primary][index]
24
- if cached
25
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
26
- @index = cached.interval.end
27
- end
28
- return cached
29
- end
30
-
31
- r0 = _nt_message_ids
32
- r0.extend(Primary0)
33
-
34
- node_cache[:primary][start_index] = r0
35
-
36
- r0
37
- end
38
-
39
- end
40
-
41
- class MessageIdsParser < Treetop::Runtime::CompiledParser
42
- include MessageIds
43
- end
44
-
45
- end