Skip to content

Commit 3660997

Browse files
committed
Url::parseQuery: fixed edge case %00
1 parent 3463481 commit 3660997

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Http/Url.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,6 @@ public static function parseQuery(string $s): array
431431
$s = str_replace(['%5B', '%5b'], '[', $s);
432432
$s = preg_replace('#&([^[&=]+)([^&]*)#', '&0[$1]$2', '&' . $s);
433433
parse_str($s, $res);
434-
return $res ? $res[0] : [];
434+
return $res[0] ?? [];
435435
}
436436
}

tests/Http/Url.parseQuery.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ Assert::same(['a' => ['x' => 'val', 'y' => 'val']], Url::parseQuery('%61[x]=val&
2323
Assert::same(['a b' => 'val', 'c' => ['d e' => 'val']], Url::parseQuery('a b=val&c[d e]=val'));
2424
Assert::same(['a.b' => 'val', 'c' => ['d.e' => 'val']], Url::parseQuery('a.b=val&c[d.e]=val'));
2525
Assert::same(['key"\'' => '"\''], Url::parseQuery('key"\'="\'')); // magic quotes
26+
Assert::same([], Url::parseQuery('%00')); // null

0 commit comments

Comments
 (0)