From: Ilia Alshanetsky Date: Mon, 12 Sep 2011 17:20:24 +0000 (+0000) Subject: Fixed bug #55273 (base64_decode() with strict rejects whitespace after pad) X-Git-Tag: php-5.5.0alpha1~1167 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3d3a6a3b965fa059f30d52f8de6f4251af887f6a;p=php Fixed bug #55273 (base64_decode() with strict rejects whitespace after pad) --- diff --git a/ext/standard/base64.c b/ext/standard/base64.c index 0f261468f4..34fb4dd8a2 100644 --- a/ext/standard/base64.c +++ b/ext/standard/base64.c @@ -153,6 +153,14 @@ PHPAPI unsigned char *php_base64_decode_ex(const unsigned char *str, int length, while ((ch = *current++) != '\0' && length-- > 0) { if (ch == base64_pad) { if (*current != '=' && ((i % 4) == 1 || (strict && length > 0))) { + if ((i % 4) != 1) { + while (isspace(*(++current))) { + continue; + } + if (*current == '\0') { + continue; + } + } efree(result); return NULL; } diff --git a/ext/standard/tests/url/bug55273.phpt b/ext/standard/tests/url/bug55273.phpt new file mode 100644 index 0000000000..1408506b42 --- /dev/null +++ b/ext/standard/tests/url/bug55273.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #55273 (base64_decode() with strict rejects whitespace after pad) +--FILE-- + +--EXPECT-- +string(6) "UEhQ +" +string(3) "PHP" +string(6) "UEg= +" +string(2) "PH" +string(6) "UA== +" +string(1) "P"