diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-07-18 14:57:40 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-07-18 14:57:40 +0000 |
commit | c0087df04443e20ccd09cffe22d75774470f6853 (patch) | |
tree | a29dbd64e9f6da9c11c6c48c5642b33ac844884f | |
parent | 68a01f9cdfa90dc0195b472c0ac49c8d6d8dfbad (diff) | |
download | ruby-c0087df04443e20ccd09cffe22d75774470f6853.tar.gz |
pack.c: round down too long uuencode width
* pack.c (pack_pack): round down too long uuencode width. folding
width in uuencode format cannot be longer than 63 bytes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | pack.c | 2 | ||||
-rw-r--r-- | test/ruby/test_pack.rb | 4 |
3 files changed, 11 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Wed Jul 18 23:57:38 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * pack.c (pack_pack): round down too long uuencode width. folding + width in uuencode format cannot be longer than 63 bytes. + Wed Jul 18 23:04:18 2012 NARUSE, Yui <naruse@ruby-lang.org> * ext/dbm/dbm.c (fdbm_empty_p): fix wrong condtion introduced in r36438. @@ -927,6 +927,8 @@ pack_pack(VALUE ary, VALUE fmt) } if (len <= 2) len = 45; + else if (len > 63 && type == 'u') + len = 63; else len = len / 3 * 3; while (plen > 0) { diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb index 5ea21d7827..c72035c2e7 100644 --- a/test/ruby/test_pack.rb +++ b/test/ruby/test_pack.rb @@ -496,6 +496,10 @@ class TestPack < Test::Unit::TestCase assert_equal("M86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A\n!80``\n", ["a"*46].pack("u0")) assert_equal("M86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A\n!80``\n", ["a"*46].pack("u1")) assert_equal("M86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A\n!80``\n", ["a"*46].pack("u2")) + assert_equal(<<EXPECTED, ["a"*80].pack("u68")) +_86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A86%A +186%A86%A86%A86%A86%A86$` +EXPECTED assert_equal([""], "".unpack("u")) assert_equal(["a"], "!80``\n".unpack("u")) |