actionmailer 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionmailer might be problematic. Click here for more details.
- data/CHANGELOG +11 -0
- data/lib/action_mailer/vendor/tmail/encode.rb +1 -1
- data/lib/action_mailer/vendor/tmail/mail.rb +2 -0
- data/lib/action_mailer/vendor/tmail/quoting.rb +80 -63
- data/rakefile +119 -29
- metadata +3 -3
data/CHANGELOG
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
*0.8.1* (27th March, 2005)
|
2
|
+
|
3
|
+
* Fixed that if charset was found that the end of a mime part declaration TMail would throw an error #919 [lon@speedymac.com]
|
4
|
+
|
5
|
+
* Fixed that TMail::Unquoter would fail to recognize quoting method if it was in lowercase #919 [lon@speedymac.com]
|
6
|
+
|
7
|
+
* Fixed that TMail::Encoder would fail when it attempts to parse e-mail addresses which are encoded using something other than the messages encoding method #919 [lon@speedymac.com]
|
8
|
+
|
9
|
+
* Added rescue for missing iconv library and throws warnings if subject/body is called on a TMail object without it instead
|
10
|
+
|
11
|
+
|
1
12
|
*0.8.0* (22th March, 2005)
|
2
13
|
|
3
14
|
* Added framework support for processing incoming emails with an Action Mailer class. See example in README.
|
@@ -1,83 +1,100 @@
|
|
1
|
-
|
2
|
-
require '
|
1
|
+
begin
|
2
|
+
require 'iconv'
|
3
|
+
require 'base64'
|
3
4
|
|
4
|
-
module TMail
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
module TMail
|
6
|
+
class Mail
|
7
|
+
def subject(to_charset = 'utf-8')
|
8
|
+
Unquoter.unquote_and_convert_to(quoted_subject, to_charset)
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def unquoted_body(to_charset = 'utf-8')
|
12
|
+
Unquoter.unquote_and_convert_to(quoted_body, to_charset, header["content-type"]["charset"])
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
def body(to_charset = 'utf-8', &block)
|
16
|
+
attachment_presenter = block || Proc.new { |file_name| "Attachment: #{file_name}\n" }
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
if multipart?
|
19
|
+
parts.collect { |part|
|
20
|
+
part.header["content-type"].main_type == "text" ?
|
21
|
+
part.unquoted_body(to_charset) :
|
22
|
+
attachment_presenter.call(part.header["content-type"].params["name"])
|
23
|
+
}.join
|
24
|
+
else
|
25
|
+
unquoted_body(to_charset)
|
26
|
+
end
|
25
27
|
end
|
26
28
|
end
|
27
|
-
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
30
|
+
class Unquoter
|
31
|
+
class << self
|
32
|
+
def unquote_and_convert_to(text, to_charset, from_charset = "iso-8859-1")
|
33
|
+
return "" if text.nil?
|
34
|
+
if text =~ /^=\?(.*?)\?(.)\?(.*)\?=$/
|
35
|
+
from_charset = $1
|
36
|
+
quoting_method = $2
|
37
|
+
text = $3
|
38
|
+
case quoting_method.upcase
|
39
|
+
when "Q" then
|
40
|
+
unquote_quoted_printable_and_convert_to(text, from_charset, to_charset)
|
41
|
+
when "B" then
|
42
|
+
unquote_base64_and_convert_to(text, from_charset, to_charset)
|
43
|
+
else
|
44
|
+
raise "unknown quoting method #{quoting_method.inspect}"
|
45
|
+
end
|
46
|
+
else
|
47
|
+
unquote_quoted_printable_and_convert_to(text, from_charset, to_charset)
|
44
48
|
end
|
45
|
-
else
|
46
|
-
unquote_quoted_printable_and_convert_to(text, from_charset, to_charset)
|
47
49
|
end
|
48
|
-
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
51
|
+
def unquote_quoted_printable_and_convert_to(text, from, to)
|
52
|
+
text ? Iconv.iconv(to, from || "ISO-8859-1", text.gsub(/_/," ").unpack("M*").first).first : ""
|
53
|
+
end
|
53
54
|
|
54
|
-
|
55
|
-
|
55
|
+
def unquote_base64_and_convert_to(text, from, to)
|
56
|
+
text ? Iconv.iconv(to, from || "ISO-8859-1", Base64.decode64(text)).first : ""
|
57
|
+
end
|
56
58
|
end
|
57
59
|
end
|
58
60
|
end
|
59
|
-
end
|
60
61
|
|
61
|
-
if __FILE__ == $0
|
62
|
-
|
62
|
+
if __FILE__ == $0
|
63
|
+
require 'test/unit'
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
65
|
+
class TC_Unquoter < Test::Unit::TestCase
|
66
|
+
def test_unquote_quoted_printable
|
67
|
+
a ="=?ISO-8859-1?Q?[166417]_Bekr=E6ftelse_fra_Rejsefeber?="
|
68
|
+
b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8')
|
69
|
+
assert_equal "[166417] Bekr\303\246ftelse fra Rejsefeber", b
|
70
|
+
end
|
70
71
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
def test_unquote_base64
|
73
|
+
a ="=?ISO-8859-1?B?WzE2NjQxN10gQmVrcuZmdGVsc2UgZnJhIFJlanNlZmViZXI=?="
|
74
|
+
b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8')
|
75
|
+
assert_equal "[166417] Bekr\303\246ftelse fra Rejsefeber", b
|
76
|
+
end
|
76
77
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
def test_unquote_without_charset
|
79
|
+
a ="[166417]_Bekr=E6ftelse_fra_Rejsefeber"
|
80
|
+
b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8')
|
81
|
+
assert_equal "[166417] Bekr\303\246ftelse fra Rejsefeber", b
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
rescue LoadError => e
|
86
|
+
# Not providing quoting support
|
87
|
+
module TMail
|
88
|
+
class Mail
|
89
|
+
def subject
|
90
|
+
warn "Action Mailer: iconv couldn't be required, so the charset conversion is skipped"
|
91
|
+
quoted_subject
|
92
|
+
end
|
93
|
+
|
94
|
+
def body
|
95
|
+
warn "Action Mailer: iconv couldn't be required, so the charset conversion is skipped"
|
96
|
+
quoted_body
|
97
|
+
end
|
81
98
|
end
|
82
99
|
end
|
83
|
-
end
|
100
|
+
end
|
data/rakefile
CHANGED
@@ -8,14 +8,18 @@ require 'rake/contrib/rubyforgepublisher'
|
|
8
8
|
|
9
9
|
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
10
10
|
PKG_NAME = 'actionmailer'
|
11
|
-
PKG_VERSION = '0.8.
|
11
|
+
PKG_VERSION = '0.8.1' + PKG_BUILD
|
12
12
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
13
13
|
|
14
|
+
RELEASE_NAME = "REL #{PKG_VERSION}"
|
15
|
+
|
16
|
+
RUBY_FORGE_PROJECT = "actionmailer"
|
17
|
+
RUBY_FORGE_USER = "webster132"
|
18
|
+
|
14
19
|
desc "Default Task"
|
15
20
|
task :default => [ :test ]
|
16
21
|
|
17
22
|
# Run the unit tests
|
18
|
-
|
19
23
|
Rake::TestTask.new { |t|
|
20
24
|
t.libs << "test"
|
21
25
|
t.pattern = 'test/*_test.rb'
|
@@ -24,11 +28,11 @@ Rake::TestTask.new { |t|
|
|
24
28
|
|
25
29
|
|
26
30
|
# Genereate the RDoc documentation
|
27
|
-
|
28
31
|
Rake::RDocTask.new { |rdoc|
|
29
32
|
rdoc.rdoc_dir = 'doc'
|
30
33
|
rdoc.title = "Action Mailer -- Easy email delivery and testing"
|
31
34
|
rdoc.options << '--line-numbers --inline-source --main README'
|
35
|
+
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
32
36
|
rdoc.rdoc_files.include('README', 'CHANGELOG')
|
33
37
|
rdoc.rdoc_files.include('lib/action_mailer.rb')
|
34
38
|
rdoc.rdoc_files.include('lib/action_mailer/*.rb')
|
@@ -36,8 +40,6 @@ Rake::RDocTask.new { |rdoc|
|
|
36
40
|
|
37
41
|
|
38
42
|
# Create compressed packages
|
39
|
-
|
40
|
-
|
41
43
|
spec = Gem::Specification.new do |s|
|
42
44
|
s.platform = Gem::Platform::RUBY
|
43
45
|
s.name = PKG_NAME
|
@@ -50,7 +52,7 @@ spec = Gem::Specification.new do |s|
|
|
50
52
|
s.rubyforge_project = "actionmailer"
|
51
53
|
s.homepage = "http://www.rubyonrails.org"
|
52
54
|
|
53
|
-
s.add_dependency('actionpack', '= 1.
|
55
|
+
s.add_dependency('actionpack', '= 1.7.0' + PKG_BUILD)
|
54
56
|
|
55
57
|
s.has_rdoc = true
|
56
58
|
s.requirements << 'none'
|
@@ -69,39 +71,127 @@ Rake::GemPackageTask.new(spec) do |p|
|
|
69
71
|
end
|
70
72
|
|
71
73
|
|
72
|
-
# Publish beta gem
|
73
74
|
desc "Publish the API documentation"
|
74
75
|
task :pgem => [:package] do
|
75
76
|
Rake::SshFilePublisher.new("davidhh@comox.textdrive.com", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
|
76
77
|
end
|
77
78
|
|
78
|
-
# Publish documentation
|
79
79
|
desc "Publish the API documentation"
|
80
80
|
task :pdoc => [:rdoc] do
|
81
81
|
Rake::SshDirPublisher.new("davidhh@comox.textdrive.com", "public_html/am", "doc").upload
|
82
82
|
end
|
83
83
|
|
84
|
-
desc "Publish to RubyForge"
|
85
|
-
task :
|
86
|
-
|
87
|
-
|
84
|
+
desc "Publish the release files to RubyForge."
|
85
|
+
task :release => [:package] do
|
86
|
+
files = ["gem", "tgz", "zip"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" }
|
87
|
+
|
88
|
+
if RUBY_FORGE_PROJECT then
|
89
|
+
require 'net/http'
|
90
|
+
require 'open-uri'
|
91
|
+
|
92
|
+
project_uri = "http://rubyforge.org/projects/#{RUBY_FORGE_PROJECT}/"
|
93
|
+
project_data = open(project_uri) { |data| data.read }
|
94
|
+
group_id = project_data[/[?&]group_id=(\d+)/, 1]
|
95
|
+
raise "Couldn't get group id" unless group_id
|
96
|
+
|
97
|
+
# This echos password to shell which is a bit sucky
|
98
|
+
if ENV["RUBY_FORGE_PASSWORD"]
|
99
|
+
password = ENV["RUBY_FORGE_PASSWORD"]
|
100
|
+
else
|
101
|
+
print "#{RUBY_FORGE_USER}@rubyforge.org's password: "
|
102
|
+
password = STDIN.gets.chomp
|
103
|
+
end
|
88
104
|
|
105
|
+
login_response = Net::HTTP.start("rubyforge.org", 80) do |http|
|
106
|
+
data = [
|
107
|
+
"login=1",
|
108
|
+
"form_loginname=#{RUBY_FORGE_USER}",
|
109
|
+
"form_pw=#{password}"
|
110
|
+
].join("&")
|
111
|
+
http.post("/account/login.php", data)
|
112
|
+
end
|
89
113
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
114
|
+
cookie = login_response["set-cookie"]
|
115
|
+
raise "Login failed" unless cookie
|
116
|
+
headers = { "Cookie" => cookie }
|
117
|
+
|
118
|
+
release_uri = "http://rubyforge.org/frs/admin/?group_id=#{group_id}"
|
119
|
+
release_data = open(release_uri, headers) { |data| data.read }
|
120
|
+
package_id = release_data[/[?&]package_id=(\d+)/, 1]
|
121
|
+
raise "Couldn't get package id" unless package_id
|
122
|
+
|
123
|
+
first_file = true
|
124
|
+
release_id = ""
|
125
|
+
|
126
|
+
files.each do |filename|
|
127
|
+
basename = File.basename(filename)
|
128
|
+
file_ext = File.extname(filename)
|
129
|
+
file_data = File.open(filename, "rb") { |file| file.read }
|
130
|
+
|
131
|
+
puts "Releasing #{basename}..."
|
132
|
+
|
133
|
+
release_response = Net::HTTP.start("rubyforge.org", 80) do |http|
|
134
|
+
release_date = Time.now.strftime("%Y-%m-%d %H:%M")
|
135
|
+
type_map = {
|
136
|
+
".zip" => "3000",
|
137
|
+
".tgz" => "3110",
|
138
|
+
".gz" => "3110",
|
139
|
+
".gem" => "1400"
|
140
|
+
}; type_map.default = "9999"
|
141
|
+
type = type_map[file_ext]
|
142
|
+
boundary = "rubyqMY6QN9bp6e4kS21H4y0zxcvoor"
|
143
|
+
|
144
|
+
query_hash = if first_file then
|
145
|
+
{
|
146
|
+
"group_id" => group_id,
|
147
|
+
"package_id" => package_id,
|
148
|
+
"release_name" => RELEASE_NAME,
|
149
|
+
"release_date" => release_date,
|
150
|
+
"type_id" => type,
|
151
|
+
"processor_id" => "8000", # Any
|
152
|
+
"release_notes" => "",
|
153
|
+
"release_changes" => "",
|
154
|
+
"preformatted" => "1",
|
155
|
+
"submit" => "1"
|
156
|
+
}
|
157
|
+
else
|
158
|
+
{
|
159
|
+
"group_id" => group_id,
|
160
|
+
"release_id" => release_id,
|
161
|
+
"package_id" => package_id,
|
162
|
+
"step2" => "1",
|
163
|
+
"type_id" => type,
|
164
|
+
"processor_id" => "8000", # Any
|
165
|
+
"submit" => "Add This File"
|
166
|
+
}
|
167
|
+
end
|
168
|
+
|
169
|
+
query = "?" + query_hash.map do |(name, value)|
|
170
|
+
[name, URI.encode(value)].join("=")
|
171
|
+
end.join("&")
|
172
|
+
|
173
|
+
data = [
|
174
|
+
"--" + boundary,
|
175
|
+
"Content-Disposition: form-data; name=\"userfile\"; filename=\"#{basename}\"",
|
176
|
+
"Content-Type: application/octet-stream",
|
177
|
+
"Content-Transfer-Encoding: binary",
|
178
|
+
"", file_data, ""
|
179
|
+
].join("\x0D\x0A")
|
180
|
+
|
181
|
+
release_headers = headers.merge(
|
182
|
+
"Content-Type" => "multipart/form-data; boundary=#{boundary}"
|
183
|
+
)
|
184
|
+
|
185
|
+
target = first_file ? "/frs/admin/qrs.php" : "/frs/admin/editrelease.php"
|
186
|
+
http.post(target + query, data, release_headers)
|
187
|
+
end
|
188
|
+
|
189
|
+
if first_file then
|
190
|
+
release_id = release_response.body[/release_id=(\d+)/, 1]
|
191
|
+
raise("Couldn't get release id") unless release_id
|
192
|
+
end
|
193
|
+
|
194
|
+
first_file = false
|
104
195
|
end
|
105
|
-
|
106
|
-
|
107
|
-
end
|
196
|
+
end
|
197
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.8
|
|
3
3
|
specification_version: 1
|
4
4
|
name: actionmailer
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.8.
|
7
|
-
date: 2005-03-
|
6
|
+
version: 0.8.1
|
7
|
+
date: 2005-03-27
|
8
8
|
summary: Service layer for easy email delivery and testing.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -85,5 +85,5 @@ dependencies:
|
|
85
85
|
-
|
86
86
|
- "="
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: 1.
|
88
|
+
version: 1.7.0
|
89
89
|
version:
|