Ticket #7861: base64_decoding.patch
| File base64_decoding.patch, 3.3 kB (added by orangechicken, 2 years ago) |
|---|
-
actionmailer/lib/action_mailer/vendor/tmail/base64.rb
old new 42 42 end 43 43 44 44 def rb_decode( str, strict = false ) 45 str.unpack('m') 45 str.unpack('m').first 46 46 end 47 47 48 48 begin -
actionmailer/lib/action_mailer/vendor/tmail/quoting.rb
old new 78 78 end 79 79 80 80 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) 82 82 end 83 83 84 84 begin -
actionmailer/test/quoting_test.rb
old new 30 30 mail = TMail::Mail.parse(IO.read("#{File.dirname(__FILE__)}/fixtures/raw_email_with_partially_quoted_subject")) 31 31 assert_equal "Re: Test: \"\346\274\242\345\255\227\" mid \"\346\274\242\345\255\227\" tail", mail.subject 32 32 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 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 62 # No .so 63 end 64 end 33 65 34 66 private 35 67 36 68 # This whole thing *could* be much simpler, but I don't think Tempfile, 37 69 # popen and others exist on all platforms (like Windows). 38 70 def execute_in_sandbox(code) … … 54 86 File.delete(test_name) rescue nil 55 87 File.delete(res_name) rescue nil 56 88 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 57 93 end -
actionmailer/test/tmail_test.rb
old new 16 16 mail = TMail::Mail.parse(fixture) 17 17 assert_equal 2, mail.attachments.length 18 18 assert_equal "image/png", mail.attachments.first.content_type 19 assert_equal 1902, mail.attachments.first.length 19 20 assert_equal "application/pkcs7-signature", mail.attachments.last.content_type 20 21 end 21 22 end