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

Changeset 7476

Show
Ignore:
Timestamp:
09/14/07 05:30:52 (1 year ago)
Author:
bitsweat
Message:

Fix attachment decoding when using the TMail C extension. Closes #7861.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionmailer/CHANGELOG

    r7070 r7476  
    11*SVN* 
     2 
     3* Fix attachment decoding when using the TMail C extension.  #7861 [orangechicken] 
    24 
    35* Increase mail delivery test coverage.  #8692 [kamal] 
  • trunk/actionmailer/lib/action_mailer/vendor/tmail/base64.rb

    r2634 r7476  
    4343 
    4444    def rb_decode( str, strict = false ) 
    45       str.unpack('m') 
     45      str.unpack('m').first 
    4646    end 
    4747 
  • trunk/actionmailer/lib/action_mailer/vendor/tmail/quoting.rb

    r5080 r7476  
    7979  
    8080      def unquote_base64_and_convert_to(text, to, from) 
    81         convert_to(Base64.decode(text).first, to, from) 
     81        convert_to(Base64.decode(text), to, from) 
    8282      end 
    8383 
  • trunk/actionmailer/test/quoting_test.rb

    r5080 r7476  
    3131    assert_equal "Re: Test: \"\346\274\242\345\255\227\" mid \"\346\274\242\345\255\227\" tail", mail.subject 
    3232  end 
     33   
     34  def test_rb_decode 
     35    encoded, decoded = expected_base64_strings 
     36    assert_equal decoded, TMail::Base64.rb_decode(encoded) 
     37  end 
     38   
     39  def test_rb_encode 
     40    encoded, decoded = expected_base64_strings 
     41    assert_equal encoded.length, TMail::Base64.rb_encode(decoded).length 
     42  end 
     43   
     44  def test_rb_decode_should_match_c_decode_if_available 
     45    encoded, decoded = expected_base64_strings 
     46     
     47    begin 
     48      require 'tmail/base64.so' 
     49      assert_equal TMail::Base64.rb_decode(encoded), TMail::Base64.c_decode(encoded) 
     50    rescue LoadError 
     51      # No .so 
     52    end 
     53  end 
     54   
     55  def test_rb_encode_should_match_c_encode_if_available 
     56    encoded, decoded = expected_base64_strings 
     57     
     58    begin 
     59      require 'tmail/base64.so' 
     60      assert_equal TMail::Base64.rb_encode(decoded), TMail::Base64.c_encode(decoded) 
     61    rescue LoadError 
     62      # No .so 
     63    end 
     64  end 
    3365 
    3466  private 
    35  
     67     
    3668    # This whole thing *could* be much simpler, but I don't think Tempfile, 
    3769    # popen and others exist on all platforms (like Windows). 
     
    5587      File.delete(res_name) rescue nil 
    5688    end 
     89     
     90    def expected_base64_strings 
     91      [ File.read("#{File.dirname(__FILE__)}/fixtures/raw_base64_encoded_string"), File.read("#{File.dirname(__FILE__)}/fixtures/raw_base64_decoded_string") ] 
     92    end 
    5793end 
  • trunk/actionmailer/test/tmail_test.rb

    r6207 r7476  
    1717    assert_equal 2, mail.attachments.length 
    1818    assert_equal "image/png", mail.attachments.first.content_type 
     19    assert_equal 1902, mail.attachments.first.length 
    1920    assert_equal "application/pkcs7-signature", mail.attachments.last.content_type 
    2021  end