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: CodeIgniter\Router\RouteCollection->fillRouteParams() ErrorException on 'from' parameter containing regex pattern with '|' symbol #3048

Closed
bivanbi opened this issue May 30, 2020 · 0 comments · Fixed by #3096
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@bivanbi
Copy link
Contributor

bivanbi commented May 30, 2020

CodeIgniter\Router\RouteCollection->fillRouteParams() uses '|' as delimiter for preg_match call. This is likely to result in ErrorException or incorrect pattern matching if the pattern itself actually contains '|' character as preg_match treats all the following characters as modifiers.

This is also inconsistent with CodeIgniter\Router->checkRoutes() which uses '#' as delimiter, and is working as expected.

CodeIgniter 4 version
Release: 4.0.3
Develop: 6bd43bb

Affected module(s)
CodeIgniter\Router\RouteCollection

Expected behavior, and steps to reproduce if appropriate

  1. Create a named route with regular expression in 'from' parameter like this:
    $routes->get('system/(this|that)', 'SomeController::someMethod/$1', ['as' => 'this-or-that']);

  2. Verify that route is correctly processed by accessing /system/this and /system/that URI in a browser

  3. Call route_to('this-or-that', 'this');

Expected:
route_to() returns string '/system/this'

Actual:
Exception: ErrorException: preg_match(): Unknown modifier 't' in /php/system/Router/RouteCollection.php:1351

Context

  • OS: Ubuntu 18.04.4
  • Web server: Apache 2.4.29
  • PHP version: 7.2.24
@bivanbi bivanbi added the bug Verified issues on the current code behavior or pull requests that will fix them label May 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant