Skip to content

Commit 273fbc5

Browse files
committed
Url::unescape() unifies %aa to %AA
1 parent 5250d8c commit 273fbc5

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/Http/Url.php

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

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)