Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not decode path before matching #15

Closed
wants to merge 1 commit into from
Closed

Conversation

trowski
Copy link
Member

@trowski trowski commented Jul 4, 2024

This reverts #4. I believe https://datatracker.ietf.org/doc/html/rfc3986.html#section-2.4 was mis-interpreted. We should not be decoding the path until after matching, otherwise "/" is interpreted as separating path segments.

Matched route parameters set in attributes are decoded. This is similar to our handling of query parameters, which are also decoded before returning from Request::getQueryParameter(), etc.

See https://chat.stackoverflow.com/transcript/message/57474623#57474623.

This is a BC break and will require a new major, since routes will need to be defined using the URL encoded version. I don't anticipate this would affect many users.

@trowski trowski requested review from kelunik and bwoebi July 4, 2024 15:00
@trowski trowski mentioned this pull request Jul 4, 2024
@Nek-
Copy link

Nek- commented Sep 14, 2024

Hello, I'm indeed hitting this issue too!

Here is my case:

  • Path is /.well-known/mercure/subscriptions/https%3A%2F%2Fexample.com%2Fmy-other-topic
  • The current code is transforming it to /.well-known/mercure/subscriptions/https://example.com/my-other-topic

It prevents fastroute to route correctly with the route /.well-known/mercure/subscriptions/{topic}. Maybe adding a test case with my case would be nice?

Furthermore, I'm not sure this is a BC break. To me it's only a (serious) fix.

@kelunik
Copy link
Member

kelunik commented Sep 15, 2024

Closing this as discussed in chat: We need to decode before matching (skipping %2f), otherwise things like encoded "a" won't match as well.

@kelunik kelunik closed this Sep 15, 2024
@kelunik kelunik deleted the remove-decoding-v2 branch September 15, 2024 16:00
@kelunik
Copy link
Member

kelunik commented Sep 15, 2024

@Nek- This limitation is explicitly documented and there's a workaround: https://github.com/amphp/http-server-router?tab=readme-ov-file#limitations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants