Skip to content

Bug: Inappropriate delimiter used in fillRouteParams #2353

Closed
@korgoth

Description

@korgoth

Describe the bug
Trying to use a simple regex in the routes config file such as (a|b|c) results in an ErrorException being thrown at SYSTEMPATH/Router/RouteCollection.php at line 1331 with the error of preg_match(): Unknown modifier
Upon investigation i see that the fillRouteParams function is trying to preg_match using pipe (|) as a delimiter, which is not appropriate as the pipe is often used in regular expressions.

CodeIgniter 4 version
rc.3

Affected module(s)
Router
Reverse routing

Expected behavior, and steps to reproduce if appropriate
I expected $route->get('(a|b|c)', "Controller::index/$1", ['as' => 'testname']);
To result in calling Controller:index with either a, b or c passed as first parameter.
The excption is thrown as soon as the route config files is being read.
P.S. I also tried escaping the pipe using \| but that resulted in CodeIgniter\Router\Exceptions\RouterException thrown in SYSTEMPATH/Router/Exceptions/RouterException.php at line 10

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix themwaiting for infoIssues or pull requests that need further clarification from the author

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions