Skip to content
This repository
  • 11 commits
  • 11 files changed
  • 0 comments
  • 1 contributor
14  actionmailer/CHANGELOG
... ...
@@ -1,3 +1,7 @@
  1
+* Removed all quoting.rb type files from ActionMailer and put Mail 2.2.0 in instead [ML]
  2
+
  3
+* Lot of updates to various test cases that now work better with the new Mail and so have different expectations
  4
+
1 5
 *Rails 3.0.0 [beta 2] (April 1st, 2010)*
2 6
 
3 7
 * Added interceptors and observers from Mail [ML]
@@ -5,6 +9,16 @@
5 9
     ActionMailer::Base.register_interceptor calls Mail.register_interceptor
6 10
     ActionMailer::Base.register_observer calls Mail.register_observer
7 11
 
  12
+* Mail::Part now no longer has nil as a default charset, it is always set to something, and defaults to UTF-8
  13
+
  14
+* Added explict setting of charset in set_fields! method to make sure Mail has the user defined default
  15
+
  16
+* Removed quoting.rb and refactored for Mail to take responsibility of all quoting and auto encoding requirements for the header.
  17
+
  18
+* Fixed several tests which had incorrect encoding.
  19
+
  20
+* Changed all utf-8 to UTF-8 for consistency
  21
+
8 22
 * Whole new API added with tests.  See base.rb for full details.  Old API is deprecated.
9 23
 
10 24
 
2  actionmailer/actionmailer.gemspec
@@ -20,6 +20,6 @@ Gem::Specification.new do |s|
20 20
   s.has_rdoc = true
21 21
 
22 22
   s.add_dependency('actionpack',  version)
23  
-  s.add_dependency('mail',        '~> 2.1.5.3')
  23
+  s.add_dependency('mail',        '~> 2.2.0')
24 24
   s.add_dependency('text-format', '~> 1.0.0')
25 25
 end
1  actionmailer/lib/action_mailer.rb
@@ -46,7 +46,6 @@ module ActionMailer
46 46
   autoload :DeprecatedApi
47 47
   autoload :MailHelper
48 48
   autoload :OldApi
49  
-  autoload :Quoting
50 49
   autoload :TestCase
51 50
   autoload :TestHelper
52 51
 end
24  actionmailer/lib/action_mailer/base.rb
@@ -207,7 +207,7 @@ module ActionMailer #:nodoc:
207 207
   #   scores instead of hyphens, so <tt>Content-Transfer-Encoding:</tt>
208 208
   #   becomes <tt>:content_transfer_encoding</tt>. The defaults set by Action Mailer are:
209 209
   #   * <tt>:mime_version => "1.0"</tt>
210  
-  #   * <tt>:charset      => "utf-8",</tt>
  210
+  #   * <tt>:charset      => "UTF-8",</tt>
211 211
   #   * <tt>:content_type => "text/plain",</tt>
212 212
   #   * <tt>:parts_order  => [ "text/plain", "text/enriched", "text/html" ]</tt>
213 213
   #
@@ -264,7 +264,7 @@ module ActionMailer #:nodoc:
264 264
   #   (i.e. multiple parts are assembled from templates which specify the content type in their
265 265
   #   filenames) this variable controls how the parts are ordered.
266 266
   class Base < AbstractController::Base
267  
-    include DeliveryMethods, Quoting
  267
+    include DeliveryMethods
268 268
     abstract!
269 269
 
270 270
     include AbstractController::Logger
@@ -286,7 +286,7 @@ class Base < AbstractController::Base
286 286
     class_attribute :default_params
287 287
     self.default_params = {
288 288
       :mime_version => "1.0",
289  
-      :charset      => "utf-8",
  289
+      :charset      => "UTF-8",
290 290
       :content_type => "text/plain",
291 291
       :parts_order  => [ "text/plain", "text/enriched", "text/html" ]
292 292
     }.freeze
@@ -531,7 +531,7 @@ def mail(headers={}, &block)
531 531
 
532 532
       # Quote fields
533 533
       headers[:subject] ||= default_i18n_subject
534  
-      quote_fields!(headers, charset)
  534
+      set_fields!(headers, charset)
535 535
 
536 536
       # Render the templates and blocks
537 537
       responses, explicit_order = collect_responses_and_parts_order(headers, &block)
@@ -577,15 +577,15 @@ def default_i18n_subject #:nodoc:
577 577
       I18n.t(:subject, :scope => [:actionmailer, mailer_scope, action_name], :default => action_name.humanize)
578 578
     end
579 579
 
580  
-    # TODO: Move this into Mail
581  
-    def quote_fields!(headers, charset) #:nodoc:
  580
+    def set_fields!(headers, charset) #:nodoc:
582 581
       m = @_message
583  
-      m.subject  ||= quote_if_necessary(headers.delete(:subject), charset)          if headers[:subject]
584  
-      m.to       ||= quote_address_if_necessary(headers.delete(:to), charset)       if headers[:to]
585  
-      m.from     ||= quote_address_if_necessary(headers.delete(:from), charset)     if headers[:from]
586  
-      m.cc       ||= quote_address_if_necessary(headers.delete(:cc), charset)       if headers[:cc]
587  
-      m.bcc      ||= quote_address_if_necessary(headers.delete(:bcc), charset)      if headers[:bcc]
588  
-      m.reply_to ||= quote_address_if_necessary(headers.delete(:reply_to), charset) if headers[:reply_to]
  582
+      m.charset = charset
  583
+      m.subject  ||= headers.delete(:subject)  if headers[:subject]
  584
+      m.to       ||= headers.delete(:to)       if headers[:to]
  585
+      m.from     ||= headers.delete(:from)     if headers[:from]
  586
+      m.cc       ||= headers.delete(:cc)       if headers[:cc]
  587
+      m.bcc      ||= headers.delete(:bcc)      if headers[:bcc]
  588
+      m.reply_to ||= headers.delete(:reply_to) if headers[:reply_to]
589 589
     end
590 590
 
591 591
     def collect_responses_and_parts_order(headers) #:nodoc:
4  actionmailer/lib/action_mailer/old_api.rb
@@ -147,8 +147,8 @@ def normalize_file_hash(params)
147 147
     def create_mail 
148 148
       m = @_message
149 149
 
150  
-      quote_fields!({:subject => subject, :to => recipients, :from => from,
151  
-                    :bcc => bcc, :cc => cc, :reply_to => reply_to}, charset)
  150
+      set_fields!({:subject => subject, :to => recipients, :from => from,
  151
+                   :bcc => bcc, :cc => cc, :reply_to => reply_to}, charset)
152 152
 
153 153
       m.mime_version = mime_version    unless mime_version.nil?
154 154
       m.date         = sent_on.to_time rescue sent_on if sent_on
64  actionmailer/lib/action_mailer/quoting.rb
... ...
@@ -1,64 +0,0 @@
1  
-module ActionMailer
2  
-  module Quoting #:nodoc:
3  
-    # TODO extract this into Mail itself.
4  
-    # 
5  
-    # 
6  
-    # Convert the given text into quoted printable format, with an instruction
7  
-    # that the text be eventually interpreted in the given charset.
8  
-    def quoted_printable(text, charset)
9  
-      text = text.gsub( /[^a-z ]/i ) { quoted_printable_encode($&) }.
10  
-                  gsub( / /, "_" )
11  
-      "=?#{charset}?Q?#{text}?="
12  
-    end
13  
-
14  
-    # Convert the given character to quoted printable format, taking into
15  
-    # account multi-byte characters (if executing with $KCODE="u", for instance)
16  
-    def quoted_printable_encode(character)
17  
-      result = ""
18  
-      character.each_byte { |b| result << "=%02X" % b }
19  
-      result
20  
-    end
21  
-
22  
-    # A quick-and-dirty regexp for determining whether a string contains any
23  
-    # characters that need escaping.
24  
-    if !defined?(CHARS_NEEDING_QUOTING)
25  
-      CHARS_NEEDING_QUOTING = Regexp.new('[\000-\011\013\014\016-\037\177-\377]', nil, 'n')
26  
-    end
27  
-
28  
-    # Quote the given text if it contains any "illegal" characters
29  
-    def quote_if_necessary(text, charset)
30  
-      text = text.dup.force_encoding(Encoding::ASCII_8BIT) if text.respond_to?(:force_encoding)
31  
-
32  
-      (text =~ CHARS_NEEDING_QUOTING) ?
33  
-        quoted_printable(text, charset) :
34  
-        text
35  
-    end
36  
-
37  
-    # Quote any of the given strings if they contain any "illegal" characters
38  
-    def quote_any_if_necessary(charset, *args)
39  
-      args.map { |v| quote_if_necessary(v, charset) }
40  
-    end
41  
-
42  
-    # Quote the given address if it needs to be. The address may be a
43  
-    # regular email address, or it can be a phrase followed by an address in
44  
-    # brackets. The phrase is the only part that will be quoted, and only if
45  
-    # it needs to be. This allows extended characters to be used in the
46  
-    # "to", "from", "cc", "bcc" and "reply-to" headers.
47  
-    def quote_address_if_necessary(address, charset)
48  
-      if Array === address
49  
-        address.map { |a| quote_address_if_necessary(a, charset) }.join(", ")
50  
-      elsif address =~ /^(\S.*)\s+(<.*>)$/
51  
-        address = $2
52  
-        phrase = quote_if_necessary($1.gsub(/^['"](.*)['"]$/, '\1'), charset)
53  
-        "\"#{phrase}\" #{address}"
54  
-      else
55  
-        address
56  
-      end
57  
-    end
58  
-
59  
-    # Quote any of the given addresses, if they need to be.
60  
-    def quote_any_address_if_necessary(charset, *args)
61  
-      args.map { |v| quote_address_if_necessary(v, charset) }
62  
-    end
63  
-  end
64  
-end
6  actionmailer/lib/action_mailer/test_case.rb
@@ -8,7 +8,7 @@ def initialize(name)
8 8
   end
9 9
 
10 10
   class TestCase < ActiveSupport::TestCase
11  
-    include Quoting, TestHelper
  11
+    include TestHelper
12 12
 
13 13
     setup :initialize_test_deliveries
14 14
     setup :set_expected_mail
@@ -48,11 +48,11 @@ def set_expected_mail
48 48
 
49 49
     private
50 50
       def charset
51  
-        "utf-8"
  51
+        "UTF-8"
52 52
       end
53 53
 
54 54
       def encode(subject)
55  
-        quoted_printable(subject, charset)
  55
+        Mail::Encodings.q_value_encode(subject, charset)
56 56
       end
57 57
 
58 58
       def read_fixture(action)
85  actionmailer/test/old_base/mail_service_test.rb
@@ -105,7 +105,7 @@ def utf8_body(recipient)
105 105
     sent_on    Time.local(2004, 12, 12)
106 106
     cc         "Foo áëô îü <extended@example.net>"
107 107
     bcc        "Foo áëô îü <extended@example.net>"
108  
-    charset    "utf-8"
  108
+    charset    "UTF-8"
109 109
     
110 110
     body       "åœö blah"
111 111
   end
@@ -131,7 +131,7 @@ def multipart_with_utf8_subject(recipient)
131 131
     recipients   recipient
132 132
     subject      "Foo áëô îü"
133 133
     from         "test@example.com"
134  
-    charset      "utf-8"
  134
+    charset      "UTF-8"
135 135
 
136 136
     part "text/plain" do |p|
137 137
       p.body = "blah"
@@ -316,18 +316,15 @@ def receive(mail)
316 316
 end
317 317
 
318 318
 class ActionMailerTest < Test::Unit::TestCase
319  
-  include ActionMailer::Quoting
320 319
 
321  
-  def encode( text, charset="utf-8" )
322  
-    quoted_printable( text, charset )
  320
+  def encode( text, charset="UTF-8" )
  321
+    Mail::Encodings.q_value_encode( text, charset )
323 322
   end
324 323
 
325  
-  def new_mail( charset="utf-8" )
  324
+  def new_mail( charset="UTF-8" )
326 325
     mail = Mail.new
  326
+    mail.charset = charset
327 327
     mail.mime_version = "1.0"
328  
-    if charset
329  
-      mail.content_type ["text", "plain", { "charset" => charset }]
330  
-    end
331 328
     mail
332 329
   end
333 330
 
@@ -358,7 +355,7 @@ def test_nested_parts
358 355
     assert_equal "multipart/mixed", created.mime_type
359 356
     assert_equal "multipart/alternative", created.parts[0].mime_type
360 357
     assert_equal "bar", created.parts[0].header['foo'].to_s
361  
-    assert_nil created.parts[0].charset
  358
+    assert_not_nil created.parts[0].charset
362 359
     assert_equal "text/plain", created.parts[0].parts[0].mime_type
363 360
     assert_equal "text/html", created.parts[0].parts[1].mime_type
364 361
     assert_equal "application/octet-stream", created.parts[1].mime_type
@@ -570,7 +567,6 @@ def test_reply_to
570 567
 
571 568
   def test_iso_charset
572 569
     TestMailer.delivery_method = :test
573  
-
574 570
     expected = new_mail( "iso-8859-1" )
575 571
     expected.to      = @recipient
576 572
     expected.subject = encode "testing isø charsets", "iso-8859-1"
@@ -671,14 +667,14 @@ def test_performs_delivery_via_sendmail
671 667
   def test_unquote_quoted_printable_subject
672 668
     msg = <<EOF
673 669
 From: me@example.com
674  
-Subject: =?utf-8?Q?testing_testing_=D6=A4?=
  670
+Subject: =?UTF-8?Q?testing_testing_=D6=A4?=
675 671
 Content-Type: text/plain; charset=iso-8859-1
676 672
 
677 673
 The body
678 674
 EOF
679 675
     mail = Mail.new(msg)
680 676
     assert_equal "testing testing \326\244", mail.subject
681  
-    assert_equal "Subject: =?utf-8?Q?testing_testing_=D6=A4?=\r\n", mail[:subject].encoded
  677
+    assert_equal "Subject: testing testing =?UTF-8?Q?_=D6=A4=?=\r\n", mail[:subject].encoded
682 678
   end
683 679
 
684 680
   def test_unquote_7bit_subject
@@ -719,7 +715,7 @@ def test_unquote_quoted_printable_body
719 715
 EOF
720 716
     mail = Mail.new(msg)
721 717
     assert_equal "The=body", mail.body.to_s.strip
722  
-    assert_equal "The=3Dbody", mail.body.encoded.strip
  718
+    assert_equal "The=3Dbody=", mail.body.encoded.strip
723 719
   end
724 720
 
725 721
   def test_unquote_base64_body
@@ -740,12 +736,12 @@ def test_extended_headers
740 736
     @recipient = "Grytøyr <test@localhost>"
741 737
 
742 738
     expected = new_mail "iso-8859-1"
743  
-    expected.to      = quote_address_if_necessary @recipient, "iso-8859-1"
  739
+    expected.to      = @recipient
744 740
     expected.subject = "testing extended headers"
745 741
     expected.body    = "Nothing to see here."
746  
-    expected.from    = quote_address_if_necessary "Grytøyr <stian1@example.net>", "iso-8859-1"
747  
-    expected.cc      = quote_address_if_necessary "Grytøyr <stian2@example.net>", "iso-8859-1"
748  
-    expected.bcc     = quote_address_if_necessary "Grytøyr <stian3@example.net>", "iso-8859-1"
  742
+    expected.from    = "Grytøyr <stian1@example.net>"
  743
+    expected.cc      = "Grytøyr <stian2@example.net>"
  744
+    expected.bcc     = "Grytøyr <stian3@example.net>"
749 745
     expected.date    = Time.local 2004, 12, 12
750 746
 
751 747
     created = nil
@@ -774,13 +770,13 @@ def test_extended_headers
774 770
 
775 771
   def test_utf8_body_is_not_quoted
776 772
     @recipient = "Foo áëô îü <extended@example.net>"
777  
-    expected = new_mail "utf-8"
778  
-    expected.to      = quote_address_if_necessary @recipient, "utf-8"
779  
-    expected.subject = "testing utf-8 body"
  773
+    expected = new_mail "UTF-8"
  774
+    expected.to      = @recipient
  775
+    expected.subject = "testing UTF-8 body"
780 776
     expected.body    = "åœö blah"
781  
-    expected.from    = quote_address_if_necessary @recipient, "utf-8"
782  
-    expected.cc      = quote_address_if_necessary @recipient, "utf-8"
783  
-    expected.bcc     = quote_address_if_necessary @recipient, "utf-8"
  777
+    expected.from    = @recipient
  778
+    expected.cc      = @recipient
  779
+    expected.bcc     = @recipient
784 780
     expected.date    = Time.local 2004, 12, 12
785 781
 
786 782
     created = TestMailer.utf8_body @recipient
@@ -789,18 +785,21 @@ def test_utf8_body_is_not_quoted
789 785
 
790 786
   def test_multiple_utf8_recipients
791 787
     @recipient = ["\"Foo áëô îü\" <extended@example.net>", "\"Example Recipient\" <me@example.com>"]
792  
-    expected = new_mail "utf-8"
793  
-    expected.to      = quote_address_if_necessary @recipient, "utf-8"
794  
-    expected.subject = "testing utf-8 body"
  788
+    expected = new_mail "UTF-8"
  789
+    expected.to      = @recipient
  790
+    expected.subject = "testing UTF-8 body"
795 791
     expected.body    = "åœö blah"
796  
-    expected.from    = quote_address_if_necessary @recipient.first, "utf-8"
797  
-    expected.cc      = quote_address_if_necessary @recipient, "utf-8"
798  
-    expected.bcc     = quote_address_if_necessary @recipient, "utf-8"
  792
+    expected.from    = @recipient.first
  793
+    expected.cc      = @recipient
  794
+    expected.bcc     = @recipient
799 795
     expected.date    = Time.local 2004, 12, 12
800 796
 
801 797
     created = TestMailer.utf8_body @recipient
802  
-    assert_match(/\nFrom: =\?utf-8\?Q\?Foo_.*?\?= <extended@example.net>\r/, created.encoded)
803  
-    assert_match(/\nTo: =\?utf-8\?Q\?Foo_.*?\?= <extended@example.net>, \r\n\tExample Recipient <me/, created.encoded)
  798
+    from_regexp = Regexp.escape('From: Foo =?UTF-8?B?w6HDq8O0?= =?UTF-8?B?IMOuw7w=?=')
  799
+    assert_match(/#{from_regexp}/m, created.encoded)
  800
+
  801
+    to_regexp   = Regexp.escape("To: =?UTF-8?B?Rm9vIMOhw6vDtCDDrsO8?= <extended@example.net>")
  802
+    assert_match(/#{to_regexp}/m, created.encoded)
804 803
   end
805 804
 
806 805
   def test_receive_decodes_base64_encoded_mail
@@ -864,12 +863,20 @@ def test_multipart_with_mime_version
864 863
 
865 864
   def test_multipart_with_utf8_subject
866 865
     mail = TestMailer.multipart_with_utf8_subject(@recipient)
867  
-    assert_match(/\nSubject: =\?utf-8\?Q\?Foo_.*?\?=/, mail.encoded)
  866
+    regex = Regexp.escape('Subject: Foo =?UTF-8?Q?=C3=A1=C3=AB=C3=B4=?= =?UTF-8?Q?_=C3=AE=C3=BC=?=')
  867
+    assert_match(/#{regex}/, mail.encoded)
  868
+    string = "Foo áëô îü"
  869
+    string.force_encoding('UTF-8') if string.respond_to?(:force_encoding)
  870
+    assert_match(string, mail.subject)
868 871
   end
869 872
 
870 873
   def test_implicitly_multipart_with_utf8
871 874
     mail = TestMailer.implicitly_multipart_with_utf8
872  
-    assert_match(/\nSubject: =\?utf-8\?Q\?Foo_.*?\?=/, mail.encoded)
  875
+    regex = Regexp.escape('Subject: Foo =?UTF-8?Q?=C3=A1=C3=AB=C3=B4=?= =?UTF-8?Q?_=C3=AE=C3=BC=?=')
  876
+    assert_match(/#{regex}/, mail.encoded)
  877
+    string = "Foo áëô îü"
  878
+    string.force_encoding('UTF-8') if string.respond_to?(:force_encoding)
  879
+    assert_match(string, mail.subject)
873 880
   end
874 881
 
875 882
   def test_explicitly_multipart_messages
@@ -909,11 +916,11 @@ def test_implicitly_multipart_messages
909 916
     assert_equal "1.0", mail.mime_version.to_s
910 917
     assert_equal "multipart/alternative", mail.mime_type
911 918
     assert_equal "text/plain", mail.parts[0].mime_type
912  
-    assert_equal "utf-8", mail.parts[0].charset
  919
+    assert_equal "UTF-8", mail.parts[0].charset
913 920
     assert_equal "text/html", mail.parts[1].mime_type
914  
-    assert_equal "utf-8", mail.parts[1].charset
  921
+    assert_equal "UTF-8", mail.parts[1].charset
915 922
     assert_equal "application/x-yaml", mail.parts[2].mime_type
916  
-    assert_equal "utf-8", mail.parts[2].charset
  923
+    assert_equal "UTF-8", mail.parts[2].charset
917 924
   end
918 925
 
919 926
   def test_implicitly_multipart_messages_with_custom_order
@@ -1044,13 +1051,13 @@ def test_multipart_with_template_path_with_dots
1044 1051
     mail = FunkyPathMailer.multipart_with_template_path_with_dots(@recipient)
1045 1052
     assert_equal 2, mail.parts.length
1046 1053
     assert "text/plain", mail.parts[1].mime_type
1047  
-    assert "utf-8", mail.parts[1].charset
  1054
+    assert "UTF-8", mail.parts[1].charset
1048 1055
   end
1049 1056
 
1050 1057
   def test_custom_content_type_attributes
1051 1058
     mail = TestMailer.custom_content_type_attributes
1052 1059
     assert_match %r{format=flowed}, mail.content_type
1053  
-    assert_match %r{charset=utf-8}, mail.content_type
  1060
+    assert_match %r{charset=UTF-8}, mail.content_type
1054 1061
   end
1055 1062
 
1056 1063
   def test_return_path_with_create
5  actionmailer/test/old_base/url_test.rb
@@ -29,13 +29,12 @@ def signed_up_with_url(recipient)
29 29
 end
30 30
 
31 31
 class ActionMailerUrlTest < Test::Unit::TestCase
32  
-  include ActionMailer::Quoting
33 32
 
34  
-  def encode( text, charset="utf-8" )
  33
+  def encode( text, charset="UTF-8" )
35 34
     quoted_printable( text, charset )
36 35
   end
37 36
 
38  
-  def new_mail( charset="utf-8" )
  37
+  def new_mail( charset="UTF-8" )
39 38
     mail = Mail.new
40 39
     mail.mime_version = "1.0"
41 40
     if charset
106  actionmailer/test/quoting_test.rb
... ...
@@ -1,106 +0,0 @@
1  
-# encoding: utf-8
2  
-require 'abstract_unit'
3  
-require 'tempfile'
4  
-
5  
-class QuotingTest < Test::Unit::TestCase
6  
-  # Move some tests from TMAIL here
7  
-  def test_unquote_quoted_printable
8  
-    a ="=?ISO-8859-1?Q?[166417]_Bekr=E6ftelse_fra_Rejsefeber?="
9  
-    b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')
10  
-    assert_equal "[166417] Bekr\303\246ftelse fra Rejsefeber", b
11  
-  end
12  
-
13  
-  def test_unquote_base64
14  
-    a ="=?ISO-8859-1?B?WzE2NjQxN10gQmVrcuZmdGVsc2UgZnJhIFJlanNlZmViZXI=?="
15  
-    b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')
16  
-    assert_equal "[166417] Bekr\303\246ftelse fra Rejsefeber", b
17  
-  end
18  
-
19  
-  def test_unquote_without_charset
20  
-    a ="[166417]_Bekr=E6ftelse_fra_Rejsefeber"
21  
-    b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')
22  
-    assert_equal "[166417]_Bekr=E6ftelse_fra_Rejsefeber", b
23  
-  end
24  
-
25  
-  def test_unqoute_multiple
26  
-    a ="=?utf-8?q?Re=3A_=5B12=5D_=23137=3A_Inkonsistente_verwendung_von_=22Hin?==?utf-8?b?enVmw7xnZW4i?="
27  
-    b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')
28  
-    assert_equal "Re: [12] #137: Inkonsistente verwendung von \"Hinzuf\303\274gen\"", b
29  
-  end
30  
-
31  
-  def test_unqoute_in_the_middle
32  
-    a ="Re: Photos =?ISO-8859-1?Q?Brosch=FCre_Rand?="
33  
-    b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')
34  
-    assert_equal "Re: Photos Brosch\303\274re Rand", b
35  
-  end
36  
-
37  
-  def test_unqoute_iso
38  
-    a ="=?ISO-8859-1?Q?Brosch=FCre_Rand?="
39  
-    b = Mail::Encodings.unquote_and_convert_to(a, 'iso-8859-1')
40  
-    expected = "Brosch\374re Rand"
41  
-    expected.force_encoding 'iso-8859-1' if expected.respond_to?(:force_encoding)
42  
-    assert_equal expected, b
43  
-  end
44  
-
45  
-  def test_quote_multibyte_chars
46  
-    original = "\303\246 \303\270 and \303\245"
47  
-    original.force_encoding('ASCII-8BIT') if original.respond_to?(:force_encoding)
48  
-
49  
-    result = execute_in_sandbox(<<-CODE)
50  
-      $:.unshift(File.dirname(__FILE__) + "/../lib/")
51  
-      if RUBY_VERSION < '1.9'
52  
-        $KCODE = 'u'
53  
-      end
54  
-      require 'action_mailer/quoting'
55  
-      include ActionMailer::Quoting
56  
-      quoted_printable(#{original.inspect}, "UTF-8")
57  
-    CODE
58  
-
59  
-    unquoted = Mail::Encodings.unquote_and_convert_to(result, nil)
60  
-
61  
-    unquoted.force_encoding(Encoding::ASCII_8BIT) if unquoted.respond_to?(:force_encoding)
62  
-    original.force_encoding(Encoding::ASCII_8BIT) if original.respond_to?(:force_encoding)
63  
-
64  
-    assert_equal unquoted, original
65  
-  end
66  
-
67  
-
68  
-  # test an email that has been created using \r\n newlines, instead of
69  
-  # \n newlines.
70  
-  def test_email_quoted_with_0d0a
71  
-    mail = Mail.new(IO.read("#{File.dirname(__FILE__)}/fixtures/raw_email_quoted_with_0d0a"))
72  
-    # CHANGED: subject returns an object now
73  
-    # assert_match %r{Elapsed time}, mail.body
74  
-    assert_match %r{Elapsed time}, mail.body.to_s
75  
-  end
76  
-
77  
-  def test_email_with_partially_quoted_subject
78  
-    mail = Mail.new(IO.read("#{File.dirname(__FILE__)}/fixtures/raw_email_with_partially_quoted_subject"))
79  
-    # CHANGED: subject returns an object now
80  
-    # assert_equal "Re: Test: \"\346\274\242\345\255\227\" mid \"\346\274\242\345\255\227\" tail", mail.subject
81  
-    assert_equal "Re: Test: \"\346\274\242\345\255\227\" mid \"\346\274\242\345\255\227\" tail", mail.subject
82  
-  end
83  
-
84  
-  private
85  
-    # This whole thing *could* be much simpler, but I don't think Tempfile,
86  
-    # popen and others exist on all platforms (like Windows).
87  
-    def execute_in_sandbox(code)
88  
-      test_name = "#{File.dirname(__FILE__)}/am-quoting-test.#{$$}.rb"
89  
-      res_name = "#{File.dirname(__FILE__)}/am-quoting-test.#{$$}.out"
90  
-
91  
-      File.open(test_name, "w+") do |file|
92  
-        file.write(<<-CODE)
93  
-          block = Proc.new do
94  
-            #{code}
95  
-          end
96  
-          puts block.call
97  
-        CODE
98  
-      end
99  
-
100  
-      system("ruby #{test_name} > #{res_name}") or raise "could not run test in sandbox"
101  
-      File.read(res_name).chomp
102  
-    ensure
103  
-      File.delete(test_name) rescue nil
104  
-      File.delete(res_name) rescue nil
105  
-    end
106  
-end
6  actionmailer/test/test_helper_test.rb
@@ -34,11 +34,7 @@ def test_determine_default_mailer_raises_correct_error
34 34
   end
35 35
   
36 36
   def test_charset_is_utf_8
37  
-    assert_equal "utf-8", charset
38  
-  end
39  
-
40  
-  def test_encode
41  
-    assert_equal "=?utf-8?Q?=0Aasdf=0A?=", encode("\nasdf\n")
  37
+    assert_equal "UTF-8", charset
42 38
   end
43 39
 
44 40
   def test_assert_emails

No commit comments for this range

Something went wrong with that request. Please try again.