core
core copied to clipboard
Flight route fails to handle route if "%0A%" is presented in the REQUEST_URI
Hello,
I have this route:
Flight::route('/test',function() {
echo 'test';
});
Flight::route('*',function() {
echo 'all';
});
if i try to make a request like this:
curl https://test.local/test?key1=%0A%
all
Flight can't see router "/test"
If i try like this:
curl https://test.local/test?key1=%0A
test
everything works fine
I meet this problem too, it caused by this line of code
https://github.com/mikecao/flight/blob/b3120f8db2ae3b358c1c7a412a92d7aa008a57b4/flight/net/Router.php#L81
I don't know why query string included here, may be it's a bug or just a design.
but you can solve it by change to follow:
$path = parse_url($request->url,PHP_URL_PATH);
$url_decoded = urldecode( $path );
I believe I actually fixed this with this commit. https://github.com/flightphp/core/pull/510/commits/c7a143db0425b9b6a89e39f95a87ebfeff0f7e31