Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removed the "charset" parameter from the Content-Type header of multi…

…part sections of nested multipart messages.

Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#2109 state:committed]
  • Loading branch information...
commit c41ed929bbbe649c730a90e1f3bf8a1f88dc1f81 1 parent 38136f8
@ewoodh2o ewoodh2o authored NZKoz committed
View
5 actionmailer/lib/action_mailer/part.rb
@@ -88,7 +88,10 @@ def to_mail(defaults)
part.parts << prt
end
- part.set_content_type(real_content_type, nil, ctype_attrs) if real_content_type =~ /multipart/
+ if real_content_type =~ /multipart/

Wouldn’t real_content_type.include?(‘multipart’) be more efficient here?

@Roman2K
Roman2K added a note

@GMFlash No, matching a regular expression is faster (almost twice as fast according to a quick benchmark — at least in this particular case). Anyway, it’s far from being the bottleneck here so it doesn’t matter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ ctype_attrs.delete 'charset'
+ part.set_content_type(real_content_type, nil, ctype_attrs)
+ end
end
headers.each { |k,v| part[k] = v }
View
1  actionmailer/test/mail_service_test.rb
@@ -330,6 +330,7 @@ def test_nested_parts
assert_equal "multipart/mixed", created.content_type
assert_equal "multipart/alternative", created.parts.first.content_type
assert_equal "bar", created.parts.first.header['foo'].to_s
+ assert_nil created.parts.first.charset
assert_equal "text/plain", created.parts.first.parts.first.content_type
assert_equal "text/html", created.parts.first.parts[1].content_type
assert_equal "application/octet-stream", created.parts[1].content_type
@msheakoski

Wouldn’t real_content_type.include?(‘multipart’) be more efficient here?

@Roman2K

@GMFlash No, matching a regular expression is faster (almost twice as fast according to a quick benchmark — at least in this particular case). Anyway, it’s far from being the bottleneck here so it doesn’t matter.

Please sign in to comment.
Something went wrong with that request. Please try again.