Changeset 8257
- Timestamp:
- 12/02/07 20:31:39 (1 year ago)
- Files:
-
- trunk/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/base64.rb (modified) (2 diffs)
- trunk/actionmailer/test/fixtures/raw_email11 (deleted)
- trunk/actionmailer/test/mail_service_test.rb (modified) (1 diff)
- trunk/actionmailer/test/quoting_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/base64.rb
r8084 r8257 1 =begin rdoc 1 # = TITLE: 2 # 3 # Base64 4 # 5 # = COPYRIGHT: 6 # 7 # Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net> 8 # 9 # Permission is hereby granted, free of charge, to any person obtaining 10 # a copy of this software and associated documentation files (the 11 # "Software"), to deal in the Software without restriction, including 12 # without limitation the rights to use, copy, modify, merge, publish, 13 # distribute, sublicense, and/or sell copies of the Software, and to 14 # permit persons to whom the Software is furnished to do so, subject to 15 # the following conditions: 16 # 17 # The above copyright notice and this permission notice shall be 18 # included in all copies or substantial portions of the Software. 19 # 20 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 # 28 # Note: Originally licensed under LGPL v2+. Using MIT license for Rails 29 # with permission of Minero Aoki. 2 30 3 = Base64 handling class4 5 =end6 #--7 # Copyright (c) 1998-2003 Minero Aoki <aamine@loveruby.net>8 31 # 9 # Permission is hereby granted, free of charge, to any person obtaining10 # a copy of this software and associated documentation files (the11 # "Software"), to deal in the Software without restriction, including12 # without limitation the rights to use, copy, modify, merge, publish,13 # distribute, sublicense, and/or sell copies of the Software, and to14 # permit persons to whom the Software is furnished to do so, subject to15 # the following conditions:16 #17 # The above copyright notice and this permission notice shall be18 # included in all copies or substantial portions of the Software.19 #20 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,21 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF22 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND23 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE24 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION25 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION26 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.27 #28 # Note: Originally licensed under LGPL v2+. Using MIT license for Rails29 # with permission of Minero Aoki.30 #++31 32 32 module TMail 33 33 … … 36 36 module_function 37 37 38 def rb_folding_encode( str, eol = "\n", limit = 60 )38 def folding_encode( str, eol = "\n", limit = 60 ) 39 39 [str].pack('m') 40 40 end 41 41 42 def rb_encode( str )42 def encode( str ) 43 43 [str].pack('m').tr( "\r\n", '' ) 44 44 end 45 45 46 def rb_decode( str, strict = false )46 def decode( str, strict = false ) 47 47 str.unpack('m').first 48 end49 50 begin51 require 'tmail/base64.so'52 alias folding_encode c_folding_encode53 alias encode c_encode54 alias decode c_decode55 class << self56 alias folding_encode c_folding_encode57 alias encode c_encode58 alias decode c_decode59 end60 rescue LoadError61 alias folding_encode rb_folding_encode62 alias encode rb_encode63 alias decode rb_decode64 class << self65 alias folding_encode rb_folding_encode66 alias encode rb_encode67 alias decode rb_decode68 end69 48 end 70 49 trunk/actionmailer/test/mail_service_test.rb
r8238 r8257 853 853 end 854 854 855 def test_decode_message_with_unquoted_atchar_in_header856 fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email11")857 mail = TMail::Mail.parse(fixture)858 assert_not_nil mail.from859 end860 861 855 def test_empty_header_values_omitted 862 856 result = TestMailer.create_unnamed_attachment(@recipient).encoded trunk/actionmailer/test/quoting_test.rb
r7819 r8257 71 71 end 72 72 73 def test_ rb_decode73 def test_decode 74 74 encoded, decoded = expected_base64_strings 75 assert_equal decoded, TMail::Base64. rb_decode(encoded)75 assert_equal decoded, TMail::Base64.decode(encoded) 76 76 end 77 77 78 def test_ rb_encode78 def test_encode 79 79 encoded, decoded = expected_base64_strings 80 assert_equal encoded.length, TMail::Base64.rb_encode(decoded).length 81 end 82 83 def test_rb_decode_should_match_c_decode_if_available 84 encoded, decoded = expected_base64_strings 85 86 begin 87 require 'tmail/base64.so' 88 assert_equal TMail::Base64.rb_decode(encoded), TMail::Base64.c_decode(encoded) 89 rescue LoadError 90 # No .so 91 end 92 end 93 94 def test_rb_encode_should_match_c_encode_if_available 95 encoded, decoded = expected_base64_strings 96 97 begin 98 require 'tmail/base64.so' 99 assert_equal TMail::Base64.rb_encode(decoded), TMail::Base64.c_encode(decoded) 100 rescue LoadError 101 # No .so 102 end 80 assert_equal encoded.length, TMail::Base64.encode(decoded).length 103 81 end 104 82