core icon indicating copy to clipboard operation
core copied to clipboard

Flight route fails to handle route if "%0A%" is presented in the REQUEST_URI

Open sserg82 opened this issue 5 years ago • 1 comments

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

sserg82 avatar Aug 24 '20 12:08 sserg82

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  );

easychen avatar Aug 27 '20 15:08 easychen

I believe I actually fixed this with this commit. https://github.com/flightphp/core/pull/510/commits/c7a143db0425b9b6a89e39f95a87ebfeff0f7e31

n0nag0n avatar Jan 11 '24 23:01 n0nag0n