diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-15 08:36:38 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-15 08:36:38 +0000 |
commit | f2ee215becb62fb33dfb8e81ded65ec809a24a7f (patch) | |
tree | f5e2f4fba051aeef1f83b2c1ee27031abb577ec2 /actionmailer | |
parent | 08fd13d17c0e3f0de4403bd9b3280fe26fc75acb (diff) | |
download | rails-f2ee215becb62fb33dfb8e81ded65ec809a24a7f.tar.gz rails-f2ee215becb62fb33dfb8e81ded65ec809a24a7f.tar.bz2 rails-f2ee215becb62fb33dfb8e81ded65ec809a24a7f.zip |
Stricter matching for implicitly multipart filenames excludes files ending in unsupported extensions (such as foo.rhtml.bak) and without a two-part content type (such as foo.text.rhtml or foo.text.really.plain.rhtml). Closes #2398.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3040 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionmailer')
4 files changed, 13 insertions, 4 deletions
diff --git a/actionmailer/CHANGELOG b/actionmailer/CHANGELOG index 7254016a61..45283d11a9 100644 --- a/actionmailer/CHANGELOG +++ b/actionmailer/CHANGELOG @@ -1,3 +1,8 @@ +*SVN* + +* Stricter matching for implicitly multipart filenames excludes files ending in unsupported extensions (such as foo.rhtml.bak) and without a two-part content type (such as foo.text.rhtml or foo.text.really.plain.rhtml). #2398 [Dave Burt <dave@burt.id.au>, Jeremy Kemper] + + *1.1.3* (November 7th, 2005) * Allow Mailers to have custom initialize methods that set default instance variables for all mail actions #2563 [mrj@bigpond.net.au] diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index cc996790c8..8659489808 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -278,11 +278,13 @@ module ActionMailer if @parts.empty? templates = Dir.glob("#{template_path}/#{@template}.*") templates.each do |path| - type = (File.basename(path).split(".")[1..-2] || []).join("/") - next if type.empty? - @parts << Part.new(:content_type => type, + # TODO: don't hardcode rhtml|rxml + next unless md = /^([^\.]+)\.([^\.]+\.[^\+]+)\.(rhtml|rxml)$/.match(File.basename(path)) + template_name = "#{md.captures[0]}.#{md.captures[1]}" + content_type = md.captures[1].gsub('.', '/') + @parts << Part.new(:content_type => content_type, :disposition => "inline", :charset => charset, - :body => render_message(File.basename(path).split(".")[0..-2].join('.'), @body)) + :body => render_message(template_name, @body)) end unless @parts.empty? @content_type = "multipart/alternative" diff --git a/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.ignored.rhtml b/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.ignored.rhtml new file mode 100644 index 0000000000..6940419d47 --- /dev/null +++ b/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.ignored.rhtml @@ -0,0 +1 @@ +Ignored when searching for implicitly multipart parts. diff --git a/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.rhtml.bak b/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.rhtml.bak new file mode 100644 index 0000000000..6940419d47 --- /dev/null +++ b/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.rhtml.bak @@ -0,0 +1 @@ +Ignored when searching for implicitly multipart parts. |