Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/State/Tests/Util/RequestParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public static function parseRequestParamsProvider(): array

// urlencoded [] (square brackets) in query string.
['a%5B1%5D=%2525', ['a' => ['1' => '%25']]],

['y%5B%C2%9D=', ['79_'."\xC2\x9D" => '']],
['z%5Bg=', ['7a_g' => '']],
];
}
}
7 changes: 6 additions & 1 deletion src/State/Util/RequestParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ public static function parseRequestParams(string $source): array
// parse_str urldecodes both keys and values in resulting array.
parse_str($source, $params);

return array_combine(array_map('hex2bin', array_keys($params)), $params);
$keys = array_map(
static fn (string $key): string => preg_match('/\A(?:[0-9a-f]{2})+\z/', $key) ? hex2bin($key) : $key,
array_keys($params),
);

return array_combine($keys, $params);
}

/**
Expand Down
Loading