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

Request with a dot (".") inside a Custom Route paramter returns a 404 (not found) exception #23

Open
BartChris opened this issue Feb 26, 2021 · 2 comments

Comments

@BartChris
Copy link

BartChris commented Feb 26, 2021

Hi there,

we are encountering an error when we put dots (".") in our route parameters. Is it allowed to do that?

What are the steps to reproduce this issue?

  1. Define a custom Route in Lumberjack, with a Route Parameter
  2. Pass a route paramter which contains a dot

`
Router::get('posts/{id}', function($id) {

});
Call URL
/posts/a.b.c
`

What happens?

Server returns 404

What were you expecting to happen?

Server returns the correct page

What versions of software are you using?

Operating System: Debian Buster

PHP Version: PHP 7.4

Lumberjack Version: 5.0.0

Thank you for your support!

@BartChris BartChris changed the title Request with a dot (".") inside a Route paramter return a 404 (not found) exception Request with a dot (".") inside a Route paramter returns a 404 (not found) exception Feb 26, 2021
@BartChris BartChris changed the title Request with a dot (".") inside a Route paramter returns a 404 (not found) exception Request with a dot (".") inside a Custom Route paramter returns a 404 (not found) exception Feb 26, 2021
@BartChris
Copy link
Author

BartChris commented Feb 26, 2021

We were able to fix that by using the following
Router::get('/posts/{id}', 'Controller@showRecord')->where('id', '.*');

but are inspecting wether this might have unintended consequences.

The documentation states:
"By default, all parameters will match against all non / characters. You can make the match more specific by supplying a regular expression:"

This is probably not correct since dots seem to be not allowed witth standard settings.

Edit: We now changed it to
Router::get('posts/{id}', function () {})->where('id', '[a-zA-Z0-9_.-]+');

to avoid including slashes

@AliceKLWilliams
Copy link

I've created a Pull Request Rareloop/router#21 on the routing package to implement a fix. If this is not accepted we can update the documentation to make this clearer.

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

No branches or pull requests

2 participants