Skip to content
This repository
Browse code

* Don't add charset to content-type header for a part that contains s…

…ubparts (for AOL compatibility) #2013 [John Long]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2091 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 8373b55055f421bb48c375f69d85f6dbbe679649 1 parent a322514
Jamis Buck authored September 01, 2005
2  actionmailer/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *SVN*
2 2
 
  3
+* Don't add charset to content-type header for a part that contains subparts (for AOL compatibility) #2013 [John Long]
  4
+
3 5
 * Preserve underscores when unquoting message bodies #1930
4 6
 
5 7
 * Encode multibyte characters correctly #1894
1  actionmailer/lib/action_mailer/base.rb
@@ -225,6 +225,7 @@ def create!(method_name, *parameters) #:nodoc:
225 225
           end
226 226
           unless @parts.empty?
227 227
             @content_type = "multipart/alternative"
  228
+            @charset = nil
228 229
             @parts = sort_parts(@parts, @implicit_parts_order)
229 230
           end
230 231
         end
8  actionmailer/lib/action_mailer/vendor/tmail/header.rb
@@ -754,9 +754,11 @@ def do_accept( strategy )
754 754
         strategy.meta @main
755 755
       end
756 756
       @params.each do |k,v|
757  
-        strategy.meta ';'
758  
-        strategy.space
759  
-        strategy.kv_pair k, v
  757
+        if v
  758
+          strategy.meta ';'
  759
+          strategy.space
  760
+          strategy.kv_pair k, v
  761
+        end
760 762
       end
761 763
     end
762 764
 
20  actionmailer/test/mail_service_test.rb
@@ -128,13 +128,14 @@ def explicitly_multipart_example(recipient, ct=nil)
128 128
       :body => "123456789"
129 129
   end
130 130
 
131  
-  def implicitly_multipart_example(recipient, order = nil)
  131
+  def implicitly_multipart_example(recipient, cs = nil, order = nil)
132 132
     @recipients = recipient
133 133
     @subject    = "multipart example"
134 134
     @from       = "test@example.com"
135 135
     @sent_on    = Time.local 2004, 12, 12
136 136
     @body       = { "recipient" => recipient }
137  
-    @implicit_parts_order = order unless order.nil?
  137
+    @charset    = cs if cs
  138
+    @implicit_parts_order = order if order
138 139
   end
139 140
 
140 141
   def html_mail(recipient)
@@ -598,8 +599,7 @@ def test_explicitly_multipart_messages
598 599
   end
599 600
 
600 601
   def test_explicitly_multipart_with_content_type
601  
-    mail = TestMailer.create_explicitly_multipart_example(@recipient,
602  
-      "multipart/alternative")
  602
+    mail = TestMailer.create_explicitly_multipart_example(@recipient, "multipart/alternative")
603 603
     assert_equal 3, mail.parts.length
604 604
     assert_equal "multipart/alternative", mail.content_type
605 605
   end
@@ -624,13 +624,23 @@ def test_implicitly_multipart_messages
624 624
   end
625 625
 
626 626
   def test_implicitly_multipart_messages_with_custom_order
627  
-    mail = TestMailer.create_implicitly_multipart_example(@recipient, ["text/yaml", "text/plain"])
  627
+    mail = TestMailer.create_implicitly_multipart_example(@recipient, nil, ["text/yaml", "text/plain"])
628 628
     assert_equal 3, mail.parts.length
629 629
     assert_equal "text/html", mail.parts[0].content_type
630 630
     assert_equal "text/plain", mail.parts[1].content_type
631 631
     assert_equal "text/yaml", mail.parts[2].content_type
632 632
   end
633 633
 
  634
+  def test_implicitly_multipart_messages_with_charset
  635
+    mail = TestMailer.create_implicitly_multipart_example(@recipient, 'iso-8859-1')
  636
+
  637
+    assert_equal "multipart/alternative", mail.header['content-type'].body
  638
+    
  639
+    assert_equal 'iso-8859-1', mail.parts[0].sub_header("content-type", "charset")
  640
+    assert_equal 'iso-8859-1', mail.parts[1].sub_header("content-type", "charset")
  641
+    assert_equal 'iso-8859-1', mail.parts[2].sub_header("content-type", "charset")
  642
+  end
  643
+
634 644
   def test_html_mail
635 645
     mail = TestMailer.create_html_mail(@recipient)
636 646
     assert_equal "text/html", mail.content_type

0 notes on commit 8373b55

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