mail 1.4.1 → 1.4.2
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 +5 -0
- data/Rakefile +1 -1
- data/lib/mail/body.rb +22 -1
- data/lib/mail/message.rb +4 -2
- data/lib/mail/version.rb +1 -1
- metadata +2 -2
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
== Mon 28 Dec 2009 01:21:52 UTC Mikel Lindsaar <raasdnil@gmail.com>
|
2
|
+
|
3
|
+
* Added sorting of parts, default is text/plain, then text/enriched and text/html. Access through Body#set_sort_order and Body#sort_parts! (called from Body#encode automatically)
|
4
|
+
* Version bump to 1.4.2
|
5
|
+
|
1
6
|
== Sun Dec 27 10:38:24 UTC 2009 Mikel Lindsaar <raasdnil@gmail.com>
|
2
7
|
|
3
8
|
* Updating treetop and mail to initialize uninitialized instance variables to
|
data/Rakefile
CHANGED
data/lib/mail/body.rb
CHANGED
@@ -30,6 +30,7 @@ module Mail
|
|
30
30
|
@boundary = nil
|
31
31
|
@preamble = nil
|
32
32
|
@epilogue = nil
|
33
|
+
@part_sort_order = [ "text/plain", "text/enriched", "text/html" ]
|
33
34
|
@parts = []
|
34
35
|
if string.blank?
|
35
36
|
@raw_source = ''
|
@@ -89,7 +90,26 @@ module Mail
|
|
89
90
|
def match(regexp)
|
90
91
|
self.decoded.match(regexp)
|
91
92
|
end
|
92
|
-
|
93
|
+
|
94
|
+
# Allows you to set the sort order of the parts, overriding the default sort order.
|
95
|
+
# Defaults to 'text/plain', then 'text/enriched', then 'text/html' with any other content
|
96
|
+
# type coming after.
|
97
|
+
def set_sort_order(order)
|
98
|
+
@part_sort_order = order
|
99
|
+
end
|
100
|
+
|
101
|
+
# Allows you to sort the parts according to the default sort order, or the sort order you
|
102
|
+
# set with :set_sort_order.
|
103
|
+
#
|
104
|
+
# sort_parts! is also called from :encode, so there is no need for you to call this explicitly
|
105
|
+
def sort_parts!
|
106
|
+
order = @part_sort_order
|
107
|
+
@parts = @parts.sort do |a, b|
|
108
|
+
a_order = order.index(a.content_type.string.downcase) || 1000
|
109
|
+
b_order = order.index(b.content_type.string.downcase) || 1000
|
110
|
+
a_order <=> b_order
|
111
|
+
end
|
112
|
+
end
|
93
113
|
|
94
114
|
# Returns the raw source that the body was initialized with, without
|
95
115
|
# any tampering
|
@@ -101,6 +121,7 @@ module Mail
|
|
101
121
|
# raw source. Need to implement
|
102
122
|
def encoded
|
103
123
|
if multipart?
|
124
|
+
self.sort_parts!
|
104
125
|
encoded_parts = parts.map { |p| p.encoded }
|
105
126
|
([preamble] + encoded_parts).join(crlf_boundary) + end_boundary + epilogue.to_s
|
106
127
|
else
|
data/lib/mail/message.rb
CHANGED
@@ -486,7 +486,8 @@ module Mail
|
|
486
486
|
if body.only_us_ascii?
|
487
487
|
content_type.parameters['charset'] = 'US-ASCII'
|
488
488
|
else
|
489
|
-
|
489
|
+
warning = "Non US-ASCII detected and no charset defined.\nDefaulting to UTF-8, set your own if this is incorrect.\nCalled from:\n#{caller.join("\n")}"
|
490
|
+
STDERR.puts(warning)
|
490
491
|
content_type.parameters['charset'] = 'UTF-8'
|
491
492
|
end
|
492
493
|
end
|
@@ -498,7 +499,8 @@ module Mail
|
|
498
499
|
if body.only_us_ascii?
|
499
500
|
header['Content-Transfer-Encoding'] = '7bit'
|
500
501
|
else
|
501
|
-
|
502
|
+
warning = "Non US-ASCII detected and no content-transfer-encoding defined.\nDefaulting to 8bit, set your own if this is incorrect.\nCalled from:\n#{caller.join("\n")}"
|
503
|
+
STDERR.puts(warning)
|
502
504
|
header['Content-Transfer-Encoding'] = '8bit'
|
503
505
|
end
|
504
506
|
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.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Lindsaar
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-28 00:00:00 +11:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|