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

Escape special regex characters when matching routes #766

Merged
merged 2 commits into from
Aug 3, 2024

Conversation

aguingand
Copy link
Contributor

I noticed routes with dots inside (e.g. {post}.{slug}) does not match using route().current(). Indeed RegEx special characters are currently not escaped, so I added a remplacement for :

.*+^$()|[]

I excluded {}? chars because there are needed for parameters.

@bakerkretzmar
Copy link
Collaborator

What is your replacement actually doing exactly? And what's your use case for this?

@bakerkretzmar
Copy link
Collaborator

Oh never mind I get it. Thanks! This makes sense, I'm gonna take a look at how Laravel handles routes like this because I'm fine erroring on characters that break the actual route. Not sure if it makes a difference but I'm pretty sure ^ and | aren't valid in URLs anyway unless they're encoded.

@aguingand
Copy link
Contributor Author

Sorry I've rushed the description a little bit ! Yes the goal is to backlash these chars to be matched in the regex.
You're right ^ & | can be removed as there are encoded. Laravel seems to be ok with all these chars in a route.

@bakerkretzmar bakerkretzmar merged commit 3e68510 into tighten:2.x Aug 3, 2024
22 checks passed
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.

2 participants