* pack.c (pack_unpack): properly ignore non-base64 octets such as
UTF-8 encoded BOMs; submitted by SOUMA Yutaka <holon@radastery.jp> to fix [ruby-core:10437] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
cebb4b5ca0
commit
7f005938cf
@ -1,3 +1,9 @@
|
|||||||
|
Wed Feb 28 20:51:32 2007 URABE Shyouhei <shyouhei@ruby-lang.org>
|
||||||
|
|
||||||
|
* pack.c (pack_unpack): properly ignore non-base64 octets such as
|
||||||
|
UTF-8 encoded BOMs; submitted by SOUMA Yutaka <holon@radastery.jp>
|
||||||
|
to fix [ruby-core:10437]
|
||||||
|
|
||||||
Wed Feb 28 18:31:51 2007 NAKAMURA Usaku <usa@ruby-lang.org>
|
Wed Feb 28 18:31:51 2007 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* ext/openssl/extconf.rb: no need to check unistd.h and sys/time.h.
|
* ext/openssl/extconf.rb: no need to check unistd.h and sys/time.h.
|
||||||
|
23
pack.c
23
pack.c
@ -1794,20 +1794,27 @@ pack_unpack(VALUE str, VALUE fmt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (s < send) {
|
while (s < send) {
|
||||||
while (s[0] == '\r' || s[0] == '\n') { s++; }
|
a = b = c = d = -1;
|
||||||
if ((a = b64_xtable[(int)s[0]]) == -1) break;
|
while((a = b64_xtable[(int)(*(unsigned char*)s)]) == -1 && s < send) { s++; }
|
||||||
if ((b = b64_xtable[(int)s[1]]) == -1) break;
|
if( s >= send ) break;
|
||||||
if ((c = b64_xtable[(int)s[2]]) == -1) break;
|
s++;
|
||||||
if ((d = b64_xtable[(int)s[3]]) == -1) break;
|
while((b = b64_xtable[(int)(*(unsigned char*)s)]) == -1 && s < send) { s++; }
|
||||||
|
if( s >= send ) break;
|
||||||
|
s++;
|
||||||
|
while((c = b64_xtable[(int)(*(unsigned char*)s)]) == -1 && s < send) { if( *s == '=' ) break; s++; }
|
||||||
|
if( *s == '=' || s >= send ) break;
|
||||||
|
s++;
|
||||||
|
while((d = b64_xtable[(int)(*(unsigned char*)s)]) == -1 && s < send) { if( *s == '=' ) break; s++; }
|
||||||
|
if( *s == '=' || s >= send ) break;
|
||||||
|
s++;
|
||||||
*ptr++ = a << 2 | b >> 4;
|
*ptr++ = a << 2 | b >> 4;
|
||||||
*ptr++ = b << 4 | c >> 2;
|
*ptr++ = b << 4 | c >> 2;
|
||||||
*ptr++ = c << 6 | d;
|
*ptr++ = c << 6 | d;
|
||||||
s += 4;
|
|
||||||
}
|
}
|
||||||
if (a != -1 && b != -1) {
|
if (a != -1 && b != -1) {
|
||||||
if (s + 2 < send && s[2] == '=')
|
if (c == -1 && *s == '=')
|
||||||
*ptr++ = a << 2 | b >> 4;
|
*ptr++ = a << 2 | b >> 4;
|
||||||
if (c != -1 && s + 3 < send && s[3] == '=') {
|
else if (c != -1 && *s == '=') {
|
||||||
*ptr++ = a << 2 | b >> 4;
|
*ptr++ = a << 2 | b >> 4;
|
||||||
*ptr++ = b << 4 | c >> 2;
|
*ptr++ = b << 4 | c >> 2;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user