brefphp / bref

Serverless PHP on AWS Lambda
https://bref.sh
MIT License
3.05k stars 364 forks source link

Colons in URIs are not supported with the function runtime #1797

Closed mnapoli closed 1 month ago

mnapoli commented 2 months ago

For example /tags/john:81.

I'm opening this PR with a test case to reproduce. I don't have a fix yet.

@Nyholm the root of the exception is in https://github.com/Nyholm/psr7, specifically here:

https://github.com/Nyholm/psr7/blob/229484fc939a76a6579e331b55d86a77fb8e2863/src/Uri.php#L54-L56

This is caused by PHP not supporting these URIs in parse_url: https://3v4l.org/jpiQo

https://github.com/php/php-src/issues/12703

Any idea whether https://github.com/Nyholm/psr7 could have a workaround to support these URIs? Should I open a bug there? (do you want to address this?)

GrahamCampbell commented 2 months ago

Strictly speaking, this is an invalid URL. The colon should be %3A.

Nyholm commented 2 months ago

Yeah. I was about to say the same as Graham. If it is a valid url, then we should support it. But if it is invalid, then an exception should be thrown.

mnapoli commented 2 months ago

hold on good points, I actually got the report that it was happening both with and without the encoding, I should have made it clearer (and I went with the easiest repro, which may have been a mistake from me). I'll investigate and report back.

mnapoli commented 1 month ago

It turns out the root of the problem is API Gateway v2: it decodes encoded paths. That means that we receive them "invalid" (uri-decoded).

API Gateway v1 and Lambda Function URLs do not do this. I'm not sure there's an easy solution here unfortunately. I want to move most of Bref's defaults to FURL eventually, so this problem should disappear at some point.