mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
Fixed bug #55273 (base64_decode() with strict rejects whitespace after pad)
This commit is contained in:
parent
1e4dac2d58
commit
3d3a6a3b96
@ -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;
|
||||
}
|
||||
|
25
ext/standard/tests/url/bug55273.phpt
Normal file
25
ext/standard/tests/url/bug55273.phpt
Normal file
@ -0,0 +1,25 @@
|
||||
--TEST--
|
||||
Bug #55273 (base64_decode() with strict rejects whitespace after pad)
|
||||
--FILE--
|
||||
<?php
|
||||
function test($s) {
|
||||
$v = chunk_split(base64_encode($s));
|
||||
$r = base64_decode($v, True);
|
||||
var_dump($v, $r);
|
||||
}
|
||||
|
||||
test('PHP');
|
||||
test('PH');
|
||||
test('P');
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
string(6) "UEhQ
|
||||
"
|
||||
string(3) "PHP"
|
||||
string(6) "UEg=
|
||||
"
|
||||
string(2) "PH"
|
||||
string(6) "UA==
|
||||
"
|
||||
string(1) "P"
|
Loading…
Reference in New Issue
Block a user