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

URL-encode fewer special characters inside in route parameters #662

Merged
merged 1 commit into from
Sep 1, 2023

Conversation

bakerkretzmar
Copy link
Collaborator

This PR stops URL-encoding any of the following characters when they appear inside route parameter values:

/ @ : ; , = + ! * | ? & # %

The issue of (not) encoding parameters originally came up in #118, because & wasn't being encoded in the query string and this was breaking parsing of the query, but the solution in #124 (encodeURIComponent() all parameters) went too far I think—to fix that specific issue it was important to encode query parameters, but not necessarily anything else.

A related issue came up in #490, where mens/blazers was unintentionally encoded as mens%2Fblazers, and my fix in #500 specifically skipped encoding / in certain scenarios.

But Laravel's route() function actually skips encoding a bunch of special characters in any named route parameters: RouteUrlGenerator. I'm wondering if we should just do that too. qs handles encoding/decoding query parameters for us, which isn't affected by this PR, but Laravel actually doesn't encode very much inside actual route parameters.

It's important to note here that these URLs are functionally identical whether they're encoded or not. Laravel interprets a/b and a%2Fb exactly the same, regardless of whether they appear in the last route parameter and/or have a wildcard regex explicitly allowing slashes.

See #118, #124, #490, #500, #661, and laravel/framework#22125.

@bakerkretzmar bakerkretzmar self-assigned this Aug 18, 2023
@bakerkretzmar bakerkretzmar merged commit 7923376 into main Sep 1, 2023
@bakerkretzmar bakerkretzmar deleted the skip-some-encoding branch September 1, 2023 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant