-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
bugVerified issues on the current code behavior or pull requests that will fix themVerified issues on the current code behavior or pull requests that will fix them
Description
PHP Version
8.1
CodeIgniter4 Version
4.3.1 and develop ea1b628
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter)
Which operating systems have you tested for this bug?
macOS
Which server did you use?
cli-server (PHP built-in webserver)
Database
n/a
What happened?
When enabling Auto Routing (Legacy), if we navigate to the URI that does not exist,
global filters are executed.
Steps to Reproduce
--- a/app/Config/Filters.php
+++ b/app/Config/Filters.php
@@ -31,7 +31,7 @@ class Filters extends BaseConfig
'before' => [
// 'honeypot',
// 'csrf',
- // 'invalidchars',
+ 'invalidchars',
],
'after' => [
'toolbar',--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -19,7 +19,7 @@ $routes->set404Override();
// where controller filters or CSRF protection are bypassed.
// If you don't want to define all routes, please use the Auto Routing (Improved).
// Set `$autoRoutesImproved` to true in `app/Config/Feature.php` and set the following to true.
-// $routes->setAutoRoute(false);
+$routes->setAutoRoute(true);
/*
* --------------------------------------------------------------------Navigate to http://localhost:8080/xxx.
The stack trace:
InvalidChars.php:52, CodeIgniter\Filters\InvalidChars->before()
Filters.php:173, CodeIgniter\Filters\Filters->run()
CodeIgniter.php:473, CodeIgniter\CodeIgniter->handleRequest()
CodeIgniter.php:368, CodeIgniter\CodeIgniter->run()
index.php:67, require_once()
rewrite.php:47, {main}()
Expected Output
No filter is executed.
Anything else?
But if we navigate to http://localhost:8080/404, no filter is executed.
Because 404 is invalid as a classname, and throw an exception here:
CodeIgniter4/system/Router/AutoRouter.php
Lines 98 to 100 in ea1b628
| if (! $this->isValidSegment($controllerName)) { | |
| throw new PageNotFoundException($this->controller . ' is not a valid controller name'); | |
| } |
Metadata
Metadata
Assignees
Labels
bugVerified issues on the current code behavior or pull requests that will fix themVerified issues on the current code behavior or pull requests that will fix them