mail 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of mail might be problematic. Click here for more details.
- data/CHANGELOG.rdoc +28 -0
- data/Manifest.txt +7 -6
- data/README.rdoc +19 -0
- data/Rakefile +3 -0
- data/lib/mail.rb +4 -3
- data/lib/mail/attachment.rb +9 -1
- data/lib/mail/body.rb +2 -2
- data/lib/mail/core_extensions/string.rb +0 -8
- data/lib/mail/elements/content_location_element.rb +25 -0
- data/lib/mail/encodings/encodings.rb +4 -0
- data/lib/mail/field.rb +32 -15
- data/lib/mail/fields/common/parameter_hash.rb +31 -0
- data/lib/mail/fields/content_disposition_field.rb +13 -1
- data/lib/mail/fields/content_location_field.rb +28 -0
- data/lib/mail/fields/content_type_field.rb +41 -5
- data/lib/mail/header.rb +25 -10
- data/lib/mail/message.rb +4 -0
- data/lib/mail/network/deliverable.rb +5 -1
- data/lib/mail/parsers/content_disposition.rb +14 -3
- data/lib/mail/parsers/content_disposition.treetop +3 -2
- data/lib/mail/parsers/content_location.rb +133 -0
- data/lib/mail/parsers/content_location.treetop +20 -0
- data/lib/mail/part.rb +19 -4
- data/lib/mail/version.rb +1 -1
- data/lib/mail/version_specific/ruby_1_8.rb +5 -2
- data/lib/mail/version_specific/ruby_1_9.rb +6 -0
- metadata +19 -7
- data/lib/mail/version_specific/multibyte.rb +0 -62
- data/lib/mail/version_specific/multibyte/chars.rb +0 -701
- data/lib/mail/version_specific/multibyte/exceptions.rb +0 -8
- data/lib/mail/version_specific/multibyte/unicode_database.rb +0 -71
- data/lib/mail/version_specific/ruby_1_8_string.rb +0 -88
data/lib/mail/header.rb
CHANGED
@@ -72,8 +72,17 @@ module Mail
|
|
72
72
|
def fields=(unfolded_fields)
|
73
73
|
@fields = Mail::FieldList.new
|
74
74
|
unfolded_fields.each do |field|
|
75
|
-
|
75
|
+
|
76
|
+
field = Field.new(field)
|
77
|
+
selected = select_field_for(field.name)
|
78
|
+
|
79
|
+
if selected.any? && limited_field?(field.name)
|
80
|
+
selected.first.update(field.name, field.value)
|
81
|
+
else
|
82
|
+
@fields << field
|
83
|
+
end
|
76
84
|
end
|
85
|
+
|
77
86
|
end
|
78
87
|
|
79
88
|
# 3.6. Field definitions
|
@@ -98,7 +107,7 @@ module Mail
|
|
98
107
|
# h['To'] #=> 'mikel@me.com'
|
99
108
|
# h['X-Mail-SPAM'] #=> ['15', '20']
|
100
109
|
def [](name)
|
101
|
-
selected =
|
110
|
+
selected = select_field_for(name)
|
102
111
|
case
|
103
112
|
when selected.length > 1
|
104
113
|
selected.map { |f| f }
|
@@ -123,24 +132,22 @@ module Mail
|
|
123
132
|
# h['X-Mail-SPAM'] = nil
|
124
133
|
# h['X-Mail-SPAM'] # => nil
|
125
134
|
def []=(name, value)
|
126
|
-
selected =
|
135
|
+
selected = select_field_for(name)
|
136
|
+
|
127
137
|
case
|
128
138
|
# User wants to delete the field
|
129
139
|
when !selected.blank? && value == nil
|
130
140
|
fields.delete_if { |f| selected.include?(f) }
|
131
141
|
|
132
142
|
# User wants to change the field
|
133
|
-
when !selected.blank? &&
|
143
|
+
when !selected.blank? && limited_field?(name)
|
144
|
+
|
134
145
|
selected.first.update(name, value)
|
135
146
|
|
136
147
|
# User wants to create the field
|
137
148
|
else
|
138
149
|
# Need to insert in correct order for trace fields
|
139
|
-
|
140
|
-
self.fields << Field.new(name)
|
141
|
-
else
|
142
|
-
self.fields << Field.new("#{name}: #{value}")
|
143
|
-
end
|
150
|
+
self.fields << Field.new(name.to_s, value)
|
144
151
|
end
|
145
152
|
end
|
146
153
|
|
@@ -148,7 +155,7 @@ module Mail
|
|
148
155
|
message-id in-reply-to references subject
|
149
156
|
return-path content-type mime-version
|
150
157
|
content-transfer-encoding content-description
|
151
|
-
content-id content-
|
158
|
+
content-id content-disposition content-location]
|
152
159
|
|
153
160
|
def encoded
|
154
161
|
buffer = ''
|
@@ -209,5 +216,13 @@ module Mail
|
|
209
216
|
self.fields = unfolded_header.split(CRLF)
|
210
217
|
end
|
211
218
|
|
219
|
+
def select_field_for(name)
|
220
|
+
fields.select { |f| f.responsible_for?(name) }
|
221
|
+
end
|
222
|
+
|
223
|
+
def limited_field?(name)
|
224
|
+
LIMITED_FIELDS.include?(name.downcase)
|
225
|
+
end
|
226
|
+
|
212
227
|
end
|
213
228
|
end
|
data/lib/mail/message.rb
CHANGED
@@ -26,7 +26,11 @@ module Mail
|
|
26
26
|
|
27
27
|
smtp = Net::SMTP.new(config.smtp[0], config.smtp[1] || 25)
|
28
28
|
if config.tls?
|
29
|
-
|
29
|
+
if OpenSSL::SSL::VERIFY_NONE.kind_of?(OpenSSL::SSL::SSLContext)
|
30
|
+
smtp.enable_tls(OpenSSL::SSL::VERIFY_NONE)
|
31
|
+
else
|
32
|
+
smtp.enable_tls
|
33
|
+
end
|
30
34
|
else
|
31
35
|
smtp.enable_starttls_auto if smtp.respond_to?(:enable_starttls_auto)
|
32
36
|
end
|
@@ -143,8 +143,19 @@ module Mail
|
|
143
143
|
if r3
|
144
144
|
r0 = r3
|
145
145
|
else
|
146
|
-
|
147
|
-
|
146
|
+
if has_terminal?('', false, index)
|
147
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + 0))
|
148
|
+
@index += 0
|
149
|
+
else
|
150
|
+
terminal_parse_failure('')
|
151
|
+
r4 = nil
|
152
|
+
end
|
153
|
+
if r4
|
154
|
+
r0 = r4
|
155
|
+
else
|
156
|
+
@index = i0
|
157
|
+
r0 = nil
|
158
|
+
end
|
148
159
|
end
|
149
160
|
end
|
150
161
|
end
|
@@ -355,4 +366,4 @@ module Mail
|
|
355
366
|
include ContentDisposition
|
356
367
|
end
|
357
368
|
|
358
|
-
end
|
369
|
+
end
|
@@ -15,12 +15,13 @@ module Mail
|
|
15
15
|
end
|
16
16
|
|
17
17
|
rule disposition_type
|
18
|
-
"inline" / "attachment" / extension_token
|
18
|
+
"inline" / "attachment" / extension_token / ''
|
19
19
|
end
|
20
20
|
|
21
21
|
rule extension_token
|
22
22
|
ietf_token / x_token
|
23
23
|
end
|
24
|
+
|
24
25
|
rule parameter
|
25
26
|
CFWS? attr:attribute "=" val:value CFWS? {
|
26
27
|
def param_hash
|
@@ -42,4 +43,4 @@ module Mail
|
|
42
43
|
end
|
43
44
|
|
44
45
|
end
|
45
|
-
end
|
46
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
# Autogenerated from a Treetop grammar. Edits may be lost.
|
2
|
+
|
3
|
+
|
4
|
+
module Mail
|
5
|
+
module ContentLocation
|
6
|
+
include Treetop::Runtime
|
7
|
+
|
8
|
+
def root
|
9
|
+
@root || :primary
|
10
|
+
end
|
11
|
+
|
12
|
+
include RFC2822
|
13
|
+
|
14
|
+
include RFC2045
|
15
|
+
|
16
|
+
module Primary0
|
17
|
+
def CFWS1
|
18
|
+
elements[0]
|
19
|
+
end
|
20
|
+
|
21
|
+
def location
|
22
|
+
elements[1]
|
23
|
+
end
|
24
|
+
|
25
|
+
def CFWS2
|
26
|
+
elements[2]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def _nt_primary
|
31
|
+
start_index = index
|
32
|
+
if node_cache[:primary].has_key?(index)
|
33
|
+
cached = node_cache[:primary][index]
|
34
|
+
@index = cached.interval.end if cached
|
35
|
+
return cached
|
36
|
+
end
|
37
|
+
|
38
|
+
i0, s0 = index, []
|
39
|
+
r1 = _nt_CFWS
|
40
|
+
s0 << r1
|
41
|
+
if r1
|
42
|
+
r2 = _nt_location
|
43
|
+
s0 << r2
|
44
|
+
if r2
|
45
|
+
r3 = _nt_CFWS
|
46
|
+
s0 << r3
|
47
|
+
end
|
48
|
+
end
|
49
|
+
if s0.last
|
50
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
51
|
+
r0.extend(Primary0)
|
52
|
+
else
|
53
|
+
@index = i0
|
54
|
+
r0 = nil
|
55
|
+
end
|
56
|
+
|
57
|
+
node_cache[:primary][start_index] = r0
|
58
|
+
|
59
|
+
r0
|
60
|
+
end
|
61
|
+
|
62
|
+
module Location0
|
63
|
+
def text_value
|
64
|
+
quoted_content.text_value
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def _nt_location
|
69
|
+
start_index = index
|
70
|
+
if node_cache[:location].has_key?(index)
|
71
|
+
cached = node_cache[:location][index]
|
72
|
+
@index = cached.interval.end if cached
|
73
|
+
return cached
|
74
|
+
end
|
75
|
+
|
76
|
+
i0 = index
|
77
|
+
r1 = _nt_quoted_string
|
78
|
+
r1.extend(Location0)
|
79
|
+
if r1
|
80
|
+
r0 = r1
|
81
|
+
else
|
82
|
+
s2, i2 = [], index
|
83
|
+
loop do
|
84
|
+
i3 = index
|
85
|
+
r4 = _nt_token
|
86
|
+
if r4
|
87
|
+
r3 = r4
|
88
|
+
else
|
89
|
+
if has_terminal?('\G[\\x3d]', true, index)
|
90
|
+
r5 = true
|
91
|
+
@index += 1
|
92
|
+
else
|
93
|
+
r5 = nil
|
94
|
+
end
|
95
|
+
if r5
|
96
|
+
r3 = r5
|
97
|
+
else
|
98
|
+
@index = i3
|
99
|
+
r3 = nil
|
100
|
+
end
|
101
|
+
end
|
102
|
+
if r3
|
103
|
+
s2 << r3
|
104
|
+
else
|
105
|
+
break
|
106
|
+
end
|
107
|
+
end
|
108
|
+
if s2.empty?
|
109
|
+
@index = i2
|
110
|
+
r2 = nil
|
111
|
+
else
|
112
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
113
|
+
end
|
114
|
+
if r2
|
115
|
+
r0 = r2
|
116
|
+
else
|
117
|
+
@index = i0
|
118
|
+
r0 = nil
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
node_cache[:location][start_index] = r0
|
123
|
+
|
124
|
+
r0
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
class ContentLocationParser < Treetop::Runtime::CompiledParser
|
130
|
+
include ContentLocation
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Mail
|
2
|
+
grammar ContentLocation
|
3
|
+
|
4
|
+
include RFC2822
|
5
|
+
include RFC2045
|
6
|
+
|
7
|
+
rule primary
|
8
|
+
CFWS location CFWS
|
9
|
+
end
|
10
|
+
|
11
|
+
rule location
|
12
|
+
quoted_string {
|
13
|
+
def text_value
|
14
|
+
quoted_content.text_value
|
15
|
+
end
|
16
|
+
} / (token / [\x3d])+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
data/lib/mail/part.rb
CHANGED
@@ -13,10 +13,10 @@ module Mail
|
|
13
13
|
self.body = attachment.encoded
|
14
14
|
else
|
15
15
|
super
|
16
|
-
if
|
17
|
-
@attachment = Mail::Attachment.new(:filename =>
|
16
|
+
if filename = attachment?
|
17
|
+
@attachment = Mail::Attachment.new(:filename => filename,
|
18
18
|
:data => body.to_s,
|
19
|
-
:encoding => content_transfer_encoding.
|
19
|
+
:encoding => content_transfer_encoding.encoding)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -33,7 +33,7 @@ module Mail
|
|
33
33
|
|
34
34
|
# Returns true if this part is an attachment
|
35
35
|
def attachment?
|
36
|
-
|
36
|
+
find_attachment
|
37
37
|
end
|
38
38
|
|
39
39
|
# Returns the attachment data if there is any
|
@@ -115,6 +115,21 @@ module Mail
|
|
115
115
|
@delivery_status_data ||= Header.new(body.to_s.gsub("\r\n\r\n", "\r\n"))
|
116
116
|
end
|
117
117
|
|
118
|
+
# Returns the filename of the attachment (if it exists) or returns nil
|
119
|
+
def find_attachment
|
120
|
+
case
|
121
|
+
when content_type && content_type.filename
|
122
|
+
filename = content_type.filename
|
123
|
+
when content_disposition && content_disposition.filename
|
124
|
+
filename = content_disposition.filename
|
125
|
+
when content_location && content_location.location
|
126
|
+
filename = content_location.location
|
127
|
+
else
|
128
|
+
filename = nil
|
129
|
+
end
|
130
|
+
filename
|
131
|
+
end
|
132
|
+
|
118
133
|
end
|
119
134
|
|
120
135
|
end
|
data/lib/mail/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikel Lindsaar
|
@@ -22,6 +22,16 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: "1.4"
|
24
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: activesupport
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "2.3"
|
34
|
+
version:
|
25
35
|
- !ruby/object:Gem::Dependency
|
26
36
|
name: mime-types
|
27
37
|
type: :runtime
|
@@ -52,9 +62,10 @@ extra_rdoc_files:
|
|
52
62
|
- README.rdoc
|
53
63
|
files:
|
54
64
|
- ./.gitignore
|
65
|
+
- ./CHANGELOG.rdoc
|
55
66
|
- ./Manifest.txt
|
56
|
-
- ./README.rdoc
|
57
67
|
- ./Rakefile
|
68
|
+
- ./README.rdoc
|
58
69
|
- ./lib/mail.rb
|
59
70
|
- ./lib/mail/attachment.rb
|
60
71
|
- ./lib/mail/body.rb
|
@@ -66,6 +77,7 @@ files:
|
|
66
77
|
- ./lib/mail/elements/address.rb
|
67
78
|
- ./lib/mail/elements/address_list.rb
|
68
79
|
- ./lib/mail/elements/content_disposition_element.rb
|
80
|
+
- ./lib/mail/elements/content_location_element.rb
|
69
81
|
- ./lib/mail/elements/content_transfer_encoding_element.rb
|
70
82
|
- ./lib/mail/elements/content_type_element.rb
|
71
83
|
- ./lib/mail/elements/date_time_element.rb
|
@@ -87,9 +99,11 @@ files:
|
|
87
99
|
- ./lib/mail/fields/common/common_date.rb
|
88
100
|
- ./lib/mail/fields/common/common_field.rb
|
89
101
|
- ./lib/mail/fields/common/common_message_id.rb
|
102
|
+
- ./lib/mail/fields/common/parameter_hash.rb
|
90
103
|
- ./lib/mail/fields/content_description_field.rb
|
91
104
|
- ./lib/mail/fields/content_disposition_field.rb
|
92
105
|
- ./lib/mail/fields/content_id_field.rb
|
106
|
+
- ./lib/mail/fields/content_location_field.rb
|
93
107
|
- ./lib/mail/fields/content_transfer_encoding_field.rb
|
94
108
|
- ./lib/mail/fields/content_type_field.rb
|
95
109
|
- ./lib/mail/fields/date_field.rb
|
@@ -124,6 +138,8 @@ files:
|
|
124
138
|
- ./lib/mail/parsers/address_lists.treetop
|
125
139
|
- ./lib/mail/parsers/content_disposition.rb
|
126
140
|
- ./lib/mail/parsers/content_disposition.treetop
|
141
|
+
- ./lib/mail/parsers/content_location.rb
|
142
|
+
- ./lib/mail/parsers/content_location.treetop
|
127
143
|
- ./lib/mail/parsers/content_transfer_encoding.rb
|
128
144
|
- ./lib/mail/parsers/content_transfer_encoding.treetop
|
129
145
|
- ./lib/mail/parsers/content_type.rb
|
@@ -151,12 +167,7 @@ files:
|
|
151
167
|
- ./lib/mail/utilities.rb
|
152
168
|
- ./lib/mail/version.rb
|
153
169
|
- ./lib/mail/version_specific/ruby_1_8.rb
|
154
|
-
- ./lib/mail/version_specific/ruby_1_8_string.rb
|
155
170
|
- ./lib/mail/version_specific/ruby_1_9.rb
|
156
|
-
- ./lib/mail/version_specific/multibyte.rb
|
157
|
-
- ./lib/mail/version_specific/multibyte/chars.rb
|
158
|
-
- ./lib/mail/version_specific/multibyte/exceptions.rb
|
159
|
-
- ./lib/mail/version_specific/multibyte/unicode_database.rb
|
160
171
|
- README.rdoc
|
161
172
|
has_rdoc: true
|
162
173
|
homepage: http://github.com/mikel/mail
|
@@ -183,6 +194,7 @@ requirements:
|
|
183
194
|
- treetop, Treetop is a Ruby-based DSL for text parsing and interpretation
|
184
195
|
- mime/types, A list of a lot of Mime Types
|
185
196
|
- tlsmail, Used for encrypted SMTP, only if you are on RUBY_VERSION <= 1.8.6
|
197
|
+
- activesupport, Because it has lots of goodies
|
186
198
|
rubyforge_project:
|
187
199
|
rubygems_version: 1.3.5
|
188
200
|
signing_key:
|