Bug: CodeIgniter\Router\RouteCollection->fillRouteParams() ErrorException on 'from' parameter containing regex pattern with '|' symbol #3048
Labels
bug
Verified issues on the current code behavior or pull requests that will fix them
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
Create a named route with regular expression in 'from' parameter like this:
$routes->get('system/(this|that)', 'SomeController::someMethod/$1', ['as' => 'this-or-that']);
Verify that route is correctly processed by accessing /system/this and /system/that URI in a browser
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
The text was updated successfully, but these errors were encountered: