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

Wrong controller filter processing because of faulty regular expression generation #1907

Closed
hwiesmann opened this issue Apr 2, 2019 · 0 comments
Assignees

Comments

@hwiesmann
Copy link

Describe the bug
Filters::processFilters methods replaces internally filter expressions with wrong regular expressions.

CodeIgniter 4 version
CodeIgniter4 Beta 0.0.1

Affected module(s)
Filters

Expected behaviour, and steps to reproduce if appropriate
Assume the following filter statement in Config/Filters.php:

public $filters = ['login' => ['before' => ['company/*']]];

This filter setting should set a filter for controller Company. Unfortunately, due to the wrong filter processing also controllers like CompanyXYZ will have the filter applied.

The reason for this wrong behaviour is that - for example - 'company/' is replaced by the regular expression 'company.+' which is basically equivalent with 'company'. But this is not correct.

The two statements responsible for the replacement are:

$path = strtolower(str_replace('/*', '*', $path));
$path = trim(str_replace('*', '.+', $path), '/ ');

I do not know why str_replace('/*', '*', $path) is required?! At least in my example this is the root for the problems.

@lonnieezell lonnieezell added this to the 4.0.0-beta.3 milestone Apr 3, 2019
@jim-parry jim-parry self-assigned this May 3, 2019
jim-parry added a commit that referenced this issue May 6, 2019
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

3 participants