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

Bug: Routing placeholder in "controller"part of route doesn't work #2787

Closed
pbquet opened this issue Apr 2, 2020 · 1 comment
Closed

Bug: Routing placeholder in "controller"part of route doesn't work #2787

pbquet opened this issue Apr 2, 2020 · 1 comment
Labels
wontfix Current code behavior being reported or fixed is intentional and won't be changed

Comments

@pbquet
Copy link

pbquet commented Apr 2, 2020

Hello,
This route work

$routes->add('{locale}/admin/parameter/base/config/(:num)', 'Admin\Base::config/$1');

but in the following one, the first placeholder doesn't work because it is in the "controller" part of the route instead of "method" part :

$routes->add('{locale}/admin/parameter/(:segment)/config/(:num)', 'Admin\$1::config/$2');

and that's because the '\' before $1 escape the '$'

It's possible to resolve this issue in "system/Router/Router.php::checkRoutes" line 470 by changing :

$val = preg_replace('#^' . $key . '$#', $val, $uri);

to

$val = preg_replace('#^' . $key . '$#',  str_replace('\\', '\\\\', $val), $uri);

What do you think ?

CodeIgniter 4 version
4.02

Affected module(s)
Router/Router.php

Context

  • OS: Windows 10
  • Web server nginx 1.14
  • PHP 7.3.15
@pbquet pbquet added the bug Verified issues on the current code behavior or pull requests that will fix them label Apr 2, 2020
@lonnieezell
Copy link
Member

We've had this brought up before but I have to turn down that feature. I view that as too big of a security risk because that allows anyone to try to load up common controller/method combos during an attempted attack. Not a good feature.

@kenjis kenjis added wontfix Current code behavior being reported or fixed is intentional and won't be changed and removed bug Verified issues on the current code behavior or pull requests that will fix them labels Mar 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix Current code behavior being reported or fixed is intentional and won't be changed
Projects
None yet
Development

No branches or pull requests

3 participants