Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7819

Show
Ignore:
Timestamp:
10/09/07 13:34:51 (1 year ago)
Author:
xal
Message:

Set default charset of MTAs to ISO instead of us-ascii (unless reported otherwise)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb

    r7476 r7819  
    99      case (content_transfer_encoding || "7bit").downcase 
    1010        when "quoted-printable" 
     11          # the default charset is set to iso-8859-1 instead of 'us-ascii'.  
     12          # This is needed as many mailer do not set the charset but send in ISO. This is only used if no charset is set. 
     13          if !from_charset.blank? && from_charset.downcase == 'us-ascii' 
     14            from_charset = 'iso-8859-1' 
     15          end 
     16           
    1117          Unquoter.unquote_quoted_printable_and_convert_to(quoted_body, 
    1218            to_charset, from_charset, true) 
  • trunk/actionmailer/test/quoting_test.rb

    r7476 r7819  
    44 
    55class QuotingTest < Test::Unit::TestCase 
     6   
     7  # Move some tests from TMAIL here 
     8  def test_unquote_quoted_printable 
     9    a ="=?ISO-8859-1?Q?[166417]_Bekr=E6ftelse_fra_Rejsefeber?="  
     10    b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8') 
     11    assert_equal "[166417] Bekr\303\246ftelse fra Rejsefeber", b 
     12  end 
     13 
     14  def test_unquote_base64 
     15    a ="=?ISO-8859-1?B?WzE2NjQxN10gQmVrcuZmdGVsc2UgZnJhIFJlanNlZmViZXI=?=" 
     16    b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8') 
     17    assert_equal "[166417] Bekr\303\246ftelse fra Rejsefeber", b 
     18  end 
     19 
     20  def test_unquote_without_charset 
     21    a ="[166417]_Bekr=E6ftelse_fra_Rejsefeber"  
     22    b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8') 
     23    assert_equal "[166417]_Bekr=E6ftelse_fra_Rejsefeber", b 
     24  end   
     25   
     26  def test_unqoute_multiple 
     27    a ="=?utf-8?q?Re=3A_=5B12=5D_=23137=3A_Inkonsistente_verwendung_von_=22Hin?==?utf-8?b?enVmw7xnZW4i?="  
     28    b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8') 
     29    assert_equal "Re: [12] #137: Inkonsistente verwendung von \"Hinzuf\303\274gen\"", b 
     30  end 
     31   
     32  def test_unqoute_in_the_middle 
     33    a ="Re: Photos =?ISO-8859-1?Q?Brosch=FCre_Rand?="  
     34    b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8') 
     35    assert_equal "Re: Photos Brosch\303\274re Rand", b 
     36  end 
     37   
     38  def test_unqoute_iso 
     39    a ="=?ISO-8859-1?Q?Brosch=FCre_Rand?="  
     40    b = TMail::Unquoter.unquote_and_convert_to(a, 'iso-8859-1') 
     41    assert_equal "Brosch\374re Rand", b 
     42  end 
     43     
    644  def test_quote_multibyte_chars 
    745    original = "\303\246 \303\270 and \303\245" 
     
    1957    assert_equal unquoted, original 
    2058  end 
    21  
     59   
     60   
    2261  # test an email that has been created using \r\n newlines, instead of 
    2362  # \n newlines. 
     
    63102    end 
    64103  end 
    65  
     104   
    66105  private 
    67106     
     
    92131    end 
    93132end 
     133