Skip to content

Commit 8ab63e8

Browse files
committed
Url::unescape() unifies %aa to %AA
1 parent 85243e5 commit 8ab63e8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Http/Url.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,9 @@ public static function unescape($s, $reserved = '%;/?:@&=+$,')
462462
// within a path segment, the characters "/", ";", "=", "?" are reserved
463463
// within a query component, the characters ";", "/", "?", ":", "@", "&", "=", "+", ",", "$" are reserved.
464464
if ($reserved !== '') {
465-
$s = preg_replace(
465+
$s = preg_replace_callback(
466466
'#%(' . substr(chunk_split(bin2hex($reserved), 2, '|'), 0, -1) . ')#i',
467-
'%25$1',
467+
function($m) { return '%25' . strtoupper($m[1]); },
468468
$s
469469
);
470470
}

tests/Http/Url.unescape.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ Assert::same( 'foo', Url::unescape('%66%6F%6F', '') );
1717
Assert::same( 'f%6F%6F', Url::unescape('%66%6F%6F', 'o') );
1818
Assert::same( '%66oo', Url::unescape('%66%6F%6F', 'f') );
1919
Assert::same( '%66%6F%6F', Url::unescape('%66%6F%6F', 'fo') );
20-
Assert::same( '%66%6f%6f', Url::unescape('%66%6f%6f', 'fo') );
20+
Assert::same( '%66%6F%6F', Url::unescape('%66%6f%6f', 'fo') );
2121
Assert::same( "%00\x01%02", Url::unescape('%00%01%02', "\x00\x02") );

0 commit comments

Comments
 (0)