otherinbox-mail 2.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +607 -0
- data/CONTRIBUTING.md +45 -0
- data/Dependencies.txt +3 -0
- data/Gemfile +26 -0
- data/Gemfile.lock +44 -0
- data/README.md +663 -0
- data/Rakefile +40 -0
- data/TODO.rdoc +9 -0
- data/lib/VERSION +4 -0
- data/lib/mail.rb +101 -0
- data/lib/mail/attachments_list.rb +104 -0
- data/lib/mail/body.rb +291 -0
- data/lib/mail/configuration.rb +75 -0
- data/lib/mail/core_extensions/nil.rb +17 -0
- data/lib/mail/core_extensions/object.rb +13 -0
- data/lib/mail/core_extensions/shell_escape.rb +56 -0
- data/lib/mail/core_extensions/smtp.rb +25 -0
- data/lib/mail/core_extensions/string.rb +33 -0
- data/lib/mail/core_extensions/string/access.rb +145 -0
- data/lib/mail/core_extensions/string/multibyte.rb +78 -0
- data/lib/mail/elements.rb +14 -0
- data/lib/mail/elements/address.rb +306 -0
- data/lib/mail/elements/address_list.rb +74 -0
- data/lib/mail/elements/content_disposition_element.rb +30 -0
- data/lib/mail/elements/content_location_element.rb +25 -0
- data/lib/mail/elements/content_transfer_encoding_element.rb +24 -0
- data/lib/mail/elements/content_type_element.rb +35 -0
- data/lib/mail/elements/date_time_element.rb +26 -0
- data/lib/mail/elements/envelope_from_element.rb +34 -0
- data/lib/mail/elements/message_ids_element.rb +29 -0
- data/lib/mail/elements/mime_version_element.rb +26 -0
- data/lib/mail/elements/phrase_list.rb +21 -0
- data/lib/mail/elements/received_element.rb +30 -0
- data/lib/mail/encodings.rb +274 -0
- data/lib/mail/encodings/7bit.rb +31 -0
- data/lib/mail/encodings/8bit.rb +31 -0
- data/lib/mail/encodings/base64.rb +33 -0
- data/lib/mail/encodings/binary.rb +31 -0
- data/lib/mail/encodings/quoted_printable.rb +38 -0
- data/lib/mail/encodings/transfer_encoding.rb +58 -0
- data/lib/mail/envelope.rb +35 -0
- data/lib/mail/field.rb +234 -0
- data/lib/mail/field_list.rb +33 -0
- data/lib/mail/fields.rb +35 -0
- data/lib/mail/fields/bcc_field.rb +56 -0
- data/lib/mail/fields/cc_field.rb +55 -0
- data/lib/mail/fields/comments_field.rb +41 -0
- data/lib/mail/fields/common/address_container.rb +16 -0
- data/lib/mail/fields/common/common_address.rb +125 -0
- data/lib/mail/fields/common/common_date.rb +42 -0
- data/lib/mail/fields/common/common_field.rb +51 -0
- data/lib/mail/fields/common/common_message_id.rb +44 -0
- data/lib/mail/fields/common/parameter_hash.rb +58 -0
- data/lib/mail/fields/content_description_field.rb +19 -0
- data/lib/mail/fields/content_disposition_field.rb +69 -0
- data/lib/mail/fields/content_id_field.rb +63 -0
- data/lib/mail/fields/content_location_field.rb +42 -0
- data/lib/mail/fields/content_transfer_encoding_field.rb +50 -0
- data/lib/mail/fields/content_type_field.rb +198 -0
- data/lib/mail/fields/date_field.rb +57 -0
- data/lib/mail/fields/from_field.rb +55 -0
- data/lib/mail/fields/in_reply_to_field.rb +55 -0
- data/lib/mail/fields/keywords_field.rb +44 -0
- data/lib/mail/fields/message_id_field.rb +83 -0
- data/lib/mail/fields/mime_version_field.rb +53 -0
- data/lib/mail/fields/optional_field.rb +13 -0
- data/lib/mail/fields/received_field.rb +75 -0
- data/lib/mail/fields/references_field.rb +55 -0
- data/lib/mail/fields/reply_to_field.rb +55 -0
- data/lib/mail/fields/resent_bcc_field.rb +55 -0
- data/lib/mail/fields/resent_cc_field.rb +55 -0
- data/lib/mail/fields/resent_date_field.rb +35 -0
- data/lib/mail/fields/resent_from_field.rb +55 -0
- data/lib/mail/fields/resent_message_id_field.rb +34 -0
- data/lib/mail/fields/resent_sender_field.rb +62 -0
- data/lib/mail/fields/resent_to_field.rb +55 -0
- data/lib/mail/fields/return_path_field.rb +65 -0
- data/lib/mail/fields/sender_field.rb +67 -0
- data/lib/mail/fields/structured_field.rb +51 -0
- data/lib/mail/fields/subject_field.rb +16 -0
- data/lib/mail/fields/to_field.rb +55 -0
- data/lib/mail/fields/unstructured_field.rb +191 -0
- data/lib/mail/header.rb +265 -0
- data/lib/mail/indifferent_hash.rb +146 -0
- data/lib/mail/mail.rb +255 -0
- data/lib/mail/matchers/has_sent_mail.rb +124 -0
- data/lib/mail/message.rb +2059 -0
- data/lib/mail/multibyte.rb +42 -0
- data/lib/mail/multibyte/chars.rb +474 -0
- data/lib/mail/multibyte/exceptions.rb +8 -0
- data/lib/mail/multibyte/unicode.rb +392 -0
- data/lib/mail/multibyte/utils.rb +60 -0
- data/lib/mail/network.rb +14 -0
- data/lib/mail/network/delivery_methods/exim.rb +53 -0
- data/lib/mail/network/delivery_methods/file_delivery.rb +40 -0
- data/lib/mail/network/delivery_methods/sendmail.rb +62 -0
- data/lib/mail/network/delivery_methods/smtp.rb +153 -0
- data/lib/mail/network/delivery_methods/smtp_connection.rb +74 -0
- data/lib/mail/network/delivery_methods/test_mailer.rb +40 -0
- data/lib/mail/network/retriever_methods/base.rb +63 -0
- data/lib/mail/network/retriever_methods/imap.rb +168 -0
- data/lib/mail/network/retriever_methods/pop3.rb +140 -0
- data/lib/mail/network/retriever_methods/test_retriever.rb +47 -0
- data/lib/mail/parsers/address_lists.rb +64 -0
- data/lib/mail/parsers/address_lists.treetop +19 -0
- data/lib/mail/parsers/content_disposition.rb +535 -0
- data/lib/mail/parsers/content_disposition.treetop +46 -0
- data/lib/mail/parsers/content_location.rb +139 -0
- data/lib/mail/parsers/content_location.treetop +20 -0
- data/lib/mail/parsers/content_transfer_encoding.rb +162 -0
- data/lib/mail/parsers/content_transfer_encoding.treetop +20 -0
- data/lib/mail/parsers/content_type.rb +967 -0
- data/lib/mail/parsers/content_type.treetop +68 -0
- data/lib/mail/parsers/date_time.rb +114 -0
- data/lib/mail/parsers/date_time.treetop +11 -0
- data/lib/mail/parsers/envelope_from.rb +194 -0
- data/lib/mail/parsers/envelope_from.treetop +32 -0
- data/lib/mail/parsers/message_ids.rb +45 -0
- data/lib/mail/parsers/message_ids.treetop +15 -0
- data/lib/mail/parsers/mime_version.rb +144 -0
- data/lib/mail/parsers/mime_version.treetop +19 -0
- data/lib/mail/parsers/phrase_lists.rb +45 -0
- data/lib/mail/parsers/phrase_lists.treetop +15 -0
- data/lib/mail/parsers/received.rb +71 -0
- data/lib/mail/parsers/received.treetop +11 -0
- data/lib/mail/parsers/rfc2045.rb +464 -0
- data/lib/mail/parsers/rfc2045.treetop +36 -0
- data/lib/mail/parsers/rfc2822.rb +5341 -0
- data/lib/mail/parsers/rfc2822.treetop +410 -0
- data/lib/mail/parsers/rfc2822_obsolete.rb +3768 -0
- data/lib/mail/parsers/rfc2822_obsolete.treetop +241 -0
- data/lib/mail/part.rb +116 -0
- data/lib/mail/parts_list.rb +55 -0
- data/lib/mail/patterns.rb +34 -0
- data/lib/mail/utilities.rb +215 -0
- data/lib/mail/version.rb +24 -0
- data/lib/mail/version_specific/ruby_1_8.rb +98 -0
- data/lib/mail/version_specific/ruby_1_9.rb +113 -0
- data/lib/tasks/corpus.rake +125 -0
- data/lib/tasks/treetop.rake +10 -0
- metadata +253 -0
@@ -0,0 +1,241 @@
|
|
1
|
+
module Mail
|
2
|
+
grammar RFC2822Obsolete
|
3
|
+
|
4
|
+
rule obs_qp
|
5
|
+
"\\" [\x00-\x7F]
|
6
|
+
end
|
7
|
+
|
8
|
+
rule obs_text
|
9
|
+
LF* CR* (obs_char LF* CR*)*
|
10
|
+
end
|
11
|
+
|
12
|
+
rule obs_char
|
13
|
+
[\x00-\x09] / # %d0-127 except CR and
|
14
|
+
[\x0B-\x0C] / # LF
|
15
|
+
[\x0E-\x7F]
|
16
|
+
end
|
17
|
+
|
18
|
+
rule obs_utext
|
19
|
+
obs_text
|
20
|
+
end
|
21
|
+
|
22
|
+
rule obs_phrase
|
23
|
+
(word / "." / "@")+
|
24
|
+
end
|
25
|
+
|
26
|
+
rule obs_phrase_list
|
27
|
+
phrase / (phrase? CFWS? "," CFWS?)+ phrase?
|
28
|
+
end
|
29
|
+
|
30
|
+
rule obs_FWS
|
31
|
+
WSP+ (CRLF WSP+)*
|
32
|
+
end
|
33
|
+
|
34
|
+
rule obs_day_of_week
|
35
|
+
CFWS? day_name CFWS?
|
36
|
+
end
|
37
|
+
|
38
|
+
rule obs_year
|
39
|
+
CFWS? (DIGIT DIGIT) CFWS?
|
40
|
+
end
|
41
|
+
|
42
|
+
rule obs_month
|
43
|
+
CFWS month_name CFWS
|
44
|
+
end
|
45
|
+
|
46
|
+
rule obs_day
|
47
|
+
CFWS? (DIGIT / (DIGIT DIGIT)) CFWS?
|
48
|
+
end
|
49
|
+
|
50
|
+
rule obs_hour
|
51
|
+
CFWS? (DIGIT DIGIT) CFWS?
|
52
|
+
end
|
53
|
+
|
54
|
+
rule obs_minute
|
55
|
+
CFWS? (DIGIT DIGIT) CFWS?
|
56
|
+
end
|
57
|
+
|
58
|
+
rule obs_second
|
59
|
+
CFWS? (DIGIT DIGIT) CFWS?
|
60
|
+
end
|
61
|
+
|
62
|
+
rule obs_zone
|
63
|
+
"UT" / "GMT" / # Universal Time
|
64
|
+
# North American UT
|
65
|
+
# offsets
|
66
|
+
"EST" / "EDT" / # Eastern: - 5/ - 4
|
67
|
+
"CST" / "CDT" / # Central: - 6/ - 5
|
68
|
+
"MST" / "MDT" / # Mountain: - 7/ - 6
|
69
|
+
"PST" / "PDT" / # Pacific: - 8/ - 7
|
70
|
+
#
|
71
|
+
[\x41-\x49] / # Military zones - "A"
|
72
|
+
[\x4B-\x5A] / # through "I" and "K"
|
73
|
+
[\x61-\x69] / # through "Z", both
|
74
|
+
[\x6B-\x7A] # upper and lower case
|
75
|
+
end
|
76
|
+
|
77
|
+
rule obs_angle_addr
|
78
|
+
CFWS? "<" obs_route? addr_spec ">" CFWS?
|
79
|
+
end
|
80
|
+
|
81
|
+
rule obs_route
|
82
|
+
CFWS? obs_domain_list ":" CFWS?
|
83
|
+
end
|
84
|
+
|
85
|
+
rule obs_domain_list
|
86
|
+
"@" domain (("," )* CFWS? "@" domain)*
|
87
|
+
end
|
88
|
+
|
89
|
+
rule obs_local_part
|
90
|
+
word ("." word)*
|
91
|
+
end
|
92
|
+
|
93
|
+
rule obs_domain
|
94
|
+
atom ("." atom)*
|
95
|
+
end
|
96
|
+
|
97
|
+
rule obs_mbox_list
|
98
|
+
(mailbox? CFWS? "," CFWS?)+ mailbox?
|
99
|
+
end
|
100
|
+
|
101
|
+
rule obs_addr_list
|
102
|
+
(address? CFWS? "," CFWS?)+ address?
|
103
|
+
end
|
104
|
+
|
105
|
+
rule obs_fields
|
106
|
+
(obs_return /
|
107
|
+
obs_received /
|
108
|
+
obs_orig_date /
|
109
|
+
obs_from /
|
110
|
+
obs_sender /
|
111
|
+
obs_reply_to /
|
112
|
+
obs_to /
|
113
|
+
obs_cc /
|
114
|
+
obs_bcc /
|
115
|
+
obs_message_id /
|
116
|
+
obs_in_reply_to /
|
117
|
+
obs_references /
|
118
|
+
obs_subject /
|
119
|
+
obs_comments /
|
120
|
+
obs_keywords /
|
121
|
+
obs_resent_date /
|
122
|
+
obs_resent_from /
|
123
|
+
obs_resent_send /
|
124
|
+
obs_resent_rply /
|
125
|
+
obs_resent_to /
|
126
|
+
obs_resent_cc /
|
127
|
+
obs_resent_bcc /
|
128
|
+
obs_resent_mid /
|
129
|
+
obs_optional)*
|
130
|
+
end
|
131
|
+
|
132
|
+
rule obs_orig_date
|
133
|
+
"Date" WSP* ":" date_time CRLF
|
134
|
+
end
|
135
|
+
|
136
|
+
rule obs_from
|
137
|
+
"From" WSP* ":" mailbox_list CRLF
|
138
|
+
end
|
139
|
+
|
140
|
+
rule obs_sender
|
141
|
+
"Sender" WSP* ":" mailbox CRLF
|
142
|
+
end
|
143
|
+
|
144
|
+
rule obs_reply_to
|
145
|
+
"Reply-To" WSP* ":" mailbox_list CRLF
|
146
|
+
end
|
147
|
+
|
148
|
+
|
149
|
+
rule obs_to
|
150
|
+
"To" WSP* ":" address_list CRLF
|
151
|
+
end
|
152
|
+
|
153
|
+
rule obs_cc
|
154
|
+
"Cc" WSP* ":" address_list CRLF
|
155
|
+
end
|
156
|
+
|
157
|
+
rule obs_bcc
|
158
|
+
"Bcc" WSP* ":" (address_list / CFWS?) CRLF
|
159
|
+
end
|
160
|
+
|
161
|
+
rule obs_message_id
|
162
|
+
"Message-ID" WSP* ":" msg_id CRLF
|
163
|
+
end
|
164
|
+
|
165
|
+
rule obs_in_reply_to
|
166
|
+
"In-Reply-To" WSP* ":" (phrase / msg_id)* CRLF
|
167
|
+
end
|
168
|
+
|
169
|
+
rule obs_references
|
170
|
+
"References" WSP* ":" (phrase / msg_id)* CRLF
|
171
|
+
end
|
172
|
+
|
173
|
+
rule obs_id_left
|
174
|
+
local_part
|
175
|
+
end
|
176
|
+
|
177
|
+
rule obs_id_right
|
178
|
+
domain
|
179
|
+
end
|
180
|
+
|
181
|
+
rule obs_subject
|
182
|
+
"Subject" WSP* ":" unstructured CRLF
|
183
|
+
end
|
184
|
+
|
185
|
+
rule obs_comments
|
186
|
+
"Comments" WSP* ":" unstructured CRLF
|
187
|
+
end
|
188
|
+
|
189
|
+
rule obs_keywords
|
190
|
+
"Keywords" WSP* ":" obs_phrase_list CRLF
|
191
|
+
end
|
192
|
+
|
193
|
+
rule obs_resent_from
|
194
|
+
"Resent-From" WSP* ":" mailbox_list CRLF
|
195
|
+
end
|
196
|
+
|
197
|
+
rule obs_resent_send
|
198
|
+
"Resent-Sender" WSP* ":" mailbox CRLF
|
199
|
+
end
|
200
|
+
|
201
|
+
rule obs_resent_date
|
202
|
+
"Resent-Date" WSP* ":" date_time CRLF
|
203
|
+
end
|
204
|
+
|
205
|
+
rule obs_resent_to
|
206
|
+
"Resent-To" WSP* ":" address_list CRLF
|
207
|
+
end
|
208
|
+
|
209
|
+
rule obs_resent_cc
|
210
|
+
"Resent-Cc" WSP* ":" address_list CRLF
|
211
|
+
end
|
212
|
+
|
213
|
+
rule obs_resent_bcc
|
214
|
+
"Resent-Bcc" WSP* ":" (address_list / CFWS?) CRLF
|
215
|
+
end
|
216
|
+
|
217
|
+
rule obs_resent_mid
|
218
|
+
"Resent-Message-ID" WSP* ":" msg_id CRLF
|
219
|
+
end
|
220
|
+
|
221
|
+
rule obs_resent_rply
|
222
|
+
"Resent-Reply-To" WSP* ":" address_list CRLF
|
223
|
+
end
|
224
|
+
|
225
|
+
rule obs_return
|
226
|
+
"Return-Path" WSP* ":" path CRLF
|
227
|
+
end
|
228
|
+
|
229
|
+
rule obs_received
|
230
|
+
"Received" WSP* ":" name_val_list CRLF
|
231
|
+
end
|
232
|
+
|
233
|
+
rule obs_path
|
234
|
+
obs_angle_addr
|
235
|
+
end
|
236
|
+
|
237
|
+
rule obs_optional
|
238
|
+
field_name WSP* ":" unstructured CRLF
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
data/lib/mail/part.rb
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Mail
|
3
|
+
class Part < Message
|
4
|
+
|
5
|
+
# Creates a new empty Content-ID field and inserts it in the correct order
|
6
|
+
# into the Header. The ContentIdField object will automatically generate
|
7
|
+
# a unique content ID if you try and encode it or output it to_s without
|
8
|
+
# specifying a content id.
|
9
|
+
#
|
10
|
+
# It will preserve the content ID you specify if you do.
|
11
|
+
def add_content_id(content_id_val = '')
|
12
|
+
header['content-id'] = content_id_val
|
13
|
+
end
|
14
|
+
|
15
|
+
# Returns true if the part has a content ID field, the field may or may
|
16
|
+
# not have a value, but the field exists or not.
|
17
|
+
def has_content_id?
|
18
|
+
header.has_content_id?
|
19
|
+
end
|
20
|
+
|
21
|
+
def inline_content_id
|
22
|
+
# TODO: Deprecated in 2.2.2 - Remove in 2.3
|
23
|
+
STDERR.puts("Part#inline_content_id is deprecated, please call Part#cid instead")
|
24
|
+
cid
|
25
|
+
end
|
26
|
+
|
27
|
+
def cid
|
28
|
+
add_content_id unless has_content_id?
|
29
|
+
uri_escape(unbracket(content_id))
|
30
|
+
end
|
31
|
+
|
32
|
+
def url
|
33
|
+
"cid:#{cid}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def inline?
|
37
|
+
header[:content_disposition].disposition_type == 'inline' if header[:content_disposition]
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_required_fields
|
41
|
+
add_content_id unless has_content_id?
|
42
|
+
super
|
43
|
+
end
|
44
|
+
|
45
|
+
def delivery_status_report_part?
|
46
|
+
(main_type =~ /message/i && sub_type =~ /delivery-status/i) && body =~ /Status:/
|
47
|
+
end
|
48
|
+
|
49
|
+
def delivery_status_data
|
50
|
+
delivery_status_report_part? ? parse_delivery_status_report : {}
|
51
|
+
end
|
52
|
+
|
53
|
+
def bounced?
|
54
|
+
if action.is_a?(Array)
|
55
|
+
!!(action.first =~ /failed/i)
|
56
|
+
else
|
57
|
+
!!(action =~ /failed/i)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
# Either returns the action if the message has just a single report, or an
|
63
|
+
# array of all the actions, one for each report
|
64
|
+
def action
|
65
|
+
get_return_values('action')
|
66
|
+
end
|
67
|
+
|
68
|
+
def final_recipient
|
69
|
+
get_return_values('final-recipient')
|
70
|
+
end
|
71
|
+
|
72
|
+
def error_status
|
73
|
+
get_return_values('status')
|
74
|
+
end
|
75
|
+
|
76
|
+
def diagnostic_code
|
77
|
+
get_return_values('diagnostic-code')
|
78
|
+
end
|
79
|
+
|
80
|
+
def remote_mta
|
81
|
+
get_return_values('remote-mta')
|
82
|
+
end
|
83
|
+
|
84
|
+
def retryable?
|
85
|
+
!(error_status =~ /^5/)
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def get_return_values(key)
|
91
|
+
if delivery_status_data[key].is_a?(Array)
|
92
|
+
delivery_status_data[key].map { |a| a.value }
|
93
|
+
else
|
94
|
+
delivery_status_data[key].value
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# A part may not have a header.... so, just init a body if no header
|
99
|
+
def parse_message
|
100
|
+
header_part, body_part = raw_source.split(/#{CRLF}#{WSP}*#{CRLF}/m, 2)
|
101
|
+
if header_part =~ HEADER_LINE
|
102
|
+
self.header = header_part
|
103
|
+
self.body = body_part
|
104
|
+
else
|
105
|
+
self.header = "Content-Type: text/plain\r\n"
|
106
|
+
self.body = raw_source
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def parse_delivery_status_report
|
111
|
+
@delivery_status_data ||= Header.new(body.to_s.gsub("\r\n\r\n", "\r\n"))
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Mail
|
2
|
+
class PartsList < Array
|
3
|
+
|
4
|
+
def attachments
|
5
|
+
Mail::AttachmentsList.new(self)
|
6
|
+
end
|
7
|
+
|
8
|
+
def collect
|
9
|
+
if block_given?
|
10
|
+
ary = PartsList.new
|
11
|
+
each { |o| ary << yield(o) }
|
12
|
+
ary
|
13
|
+
else
|
14
|
+
to_a
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
undef :map
|
19
|
+
alias_method :map, :collect
|
20
|
+
|
21
|
+
def map!
|
22
|
+
raise NoMethodError, "#map! is not defined, please call #collect and create a new PartsList"
|
23
|
+
end
|
24
|
+
|
25
|
+
def collect!
|
26
|
+
raise NoMethodError, "#collect! is not defined, please call #collect and create a new PartsList"
|
27
|
+
end
|
28
|
+
|
29
|
+
def sort
|
30
|
+
self.class.new(super)
|
31
|
+
end
|
32
|
+
|
33
|
+
def sort!(order)
|
34
|
+
sorted = self.sort do |a, b|
|
35
|
+
# OK, 10000 is arbitrary... if anyone actually wants to explicitly sort 10000 parts of a
|
36
|
+
# single email message... please show me a use case and I'll put more work into this method,
|
37
|
+
# in the meantime, it works :)
|
38
|
+
get_order_value(a, order) <=> get_order_value(b, order)
|
39
|
+
end
|
40
|
+
self.clear
|
41
|
+
sorted.each { |p| self << p }
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def get_order_value(part, order)
|
47
|
+
if part.respond_to?(:content_type)
|
48
|
+
order.index(part[:content_type].string.downcase) || 10000
|
49
|
+
else
|
50
|
+
10000
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: us-ascii
|
2
|
+
module Mail
|
3
|
+
module Patterns
|
4
|
+
white_space = %Q|\x9\x20|
|
5
|
+
text = %Q|\x1-\x8\xB\xC\xE-\x7f|
|
6
|
+
field_name = %Q|\x21-\x39\x3b-\x7e|
|
7
|
+
qp_safe = %Q|\x20-\x3c\x3e-\x7e|
|
8
|
+
|
9
|
+
aspecial = %Q|()<>[]:;@\\,."| # RFC5322
|
10
|
+
tspecial = %Q|()<>@,;:\\"/[]?=| # RFC2045
|
11
|
+
sp = %Q| |
|
12
|
+
control = %Q|\x00-\x1f\x7f-\xff|
|
13
|
+
|
14
|
+
if control.respond_to?(:force_encoding)
|
15
|
+
control = control.force_encoding(Encoding::BINARY)
|
16
|
+
end
|
17
|
+
|
18
|
+
CRLF = /\r\n/
|
19
|
+
WSP = /[#{white_space}]/
|
20
|
+
FWS = /#{CRLF}#{WSP}*/
|
21
|
+
TEXT = /[#{text}]/ # + obs-text
|
22
|
+
FIELD_NAME = /[#{field_name}]+/
|
23
|
+
FIELD_BODY = /.+/
|
24
|
+
FIELD_LINE = /^[#{field_name}]+:\s*.+$/
|
25
|
+
HEADER_LINE = /^([#{field_name}]+:\s*.+)$/
|
26
|
+
|
27
|
+
QP_UNSAFE = /[^#{qp_safe}]/
|
28
|
+
QP_SAFE = /[#{qp_safe}]/
|
29
|
+
CONTROL_CHAR = /[#{control}]/n
|
30
|
+
ATOM_UNSAFE = /[#{Regexp.quote aspecial}#{control}#{sp}]/n
|
31
|
+
PHRASE_UNSAFE = /[#{Regexp.quote aspecial}#{control}]/n
|
32
|
+
TOKEN_UNSAFE = /[#{Regexp.quote tspecial}#{control}#{sp}]/n
|
33
|
+
end
|
34
|
+
end
|