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 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.
@@ -295,7 +295,7 @@ module TMail
295
295
  else
296
296
  raise 'TMail FATAL: encoder scan fail'
297
297
  end
298
- str = m.post_match
298
+ (str = m.post_match) unless m.nil?
299
299
  end
300
300
 
301
301
  do_encode types, strs
@@ -281,6 +281,8 @@ module TMail
281
281
  when /\AFrom (\S+)/
282
282
  unixfrom = $1
283
283
 
284
+ when /^charset=.*/
285
+
284
286
  else
285
287
  raise SyntaxError, "wrong mail header: '#{line.inspect}'"
286
288
  end
@@ -1,83 +1,100 @@
1
- require 'iconv'
2
- require 'base64'
1
+ begin
2
+ require 'iconv'
3
+ require 'base64'
3
4
 
4
- module TMail
5
- class Mail
6
- def subject(to_charset = 'utf-8')
7
- Unquoter.unquote_and_convert_to(quoted_subject, to_charset)
8
- end
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
- def unquoted_body(to_charset = 'utf-8')
11
- Unquoter.unquote_and_convert_to(quoted_body, to_charset, header["content-type"]["charset"])
12
- end
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
- def body(to_charset = 'utf-8', &block)
15
- attachment_presenter = block || Proc.new { |file_name| "Attachment: #{file_name}\n" }
15
+ def body(to_charset = 'utf-8', &block)
16
+ attachment_presenter = block || Proc.new { |file_name| "Attachment: #{file_name}\n" }
16
17
 
17
- if multipart?
18
- parts.collect { |part|
19
- part.header["content-type"].main_type == "text" ?
20
- part.unquoted_body(to_charset) :
21
- attachment_presenter.call(part.header["content-type"].params["name"])
22
- }.join
23
- else
24
- unquoted_body(to_charset)
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
- class Unquoter
30
- class << self
31
- def unquote_and_convert_to(text, to_charset, from_charset = "iso-8859-1")
32
- return "" if text.nil?
33
- if text =~ /^=\?(.*?)\?(.)\?(.*)\?=$/
34
- from_charset = $1
35
- quoting_method = $2
36
- text = $3
37
- case quoting_method
38
- when "Q" then
39
- unquote_quoted_printable_and_convert_to(text, from_charset, to_charset)
40
- when "B" then
41
- unquote_base64_and_convert_to(text, from_charset, to_charset)
42
- else
43
- raise "unknown quoting method #{quoting_method.inspect}"
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
- def unquote_quoted_printable_and_convert_to(text, from, to)
51
- text ? Iconv.iconv(to, from || "ISO-8859-1", text.gsub(/_/," ").unpack("M*").first).first : ""
52
- end
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
- def unquote_base64_and_convert_to(text, from, to)
55
- text ? Iconv.iconv(to, from || "ISO-8859-1", Base64.decode64(text)).first : ""
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
- require 'test/unit'
62
+ if __FILE__ == $0
63
+ require 'test/unit'
63
64
 
64
- class TC_Unquoter < Test::Unit::TestCase
65
- def test_unquote_quoted_printable
66
- a ="=?ISO-8859-1?Q?[166417]_Bekr=E6ftelse_fra_Rejsefeber?="
67
- b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8')
68
- assert_equal "[166417] Bekr\303\246ftelse fra Rejsefeber", b
69
- end
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
- def test_unquote_base64
72
- a ="=?ISO-8859-1?B?WzE2NjQxN10gQmVrcuZmdGVsc2UgZnJhIFJlanNlZmViZXI=?="
73
- b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8')
74
- assert_equal "[166417] Bekr\303\246ftelse fra Rejsefeber", b
75
- end
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
- def test_unquote_without_charset
78
- a ="[166417]_Bekr=E6ftelse_fra_Rejsefeber"
79
- b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8')
80
- assert_equal "[166417] Bekr\303\246ftelse fra Rejsefeber", b
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.0' + PKG_BUILD
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.6.0' + PKG_BUILD)
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 :rubyforge do
86
- Rake::RubyForgePublisher.new('actionmailer', 'webster132').upload
87
- end
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
- desc "Count lines in the main rake file"
91
- task :lines do
92
- lines = 0
93
- codelines = 0
94
- Dir.foreach("lib/action_mailer") { |file_name|
95
- next unless file_name =~ /.*rb/
96
-
97
- f = File.open("lib/action_mailer/" + file_name)
98
-
99
- while line = f.gets
100
- lines += 1
101
- next if line =~ /^\s*$/
102
- next if line =~ /^\s*#/
103
- codelines += 1
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
- puts "Lines #{lines}, LOC #{codelines}"
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.0
7
- date: 2005-03-22
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.6.0
88
+ version: 1.7.0
89
89
  version: