Skip to content

Commit 31c3bc6

Browse files
committed
add fix and changelog
1 parent bff262f commit 31c3bc6

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

system/HTTP/Method.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class Method
102102
/**
103103
* Returns all HTTP methods.
104104
*
105-
* @return list<string>
105+
* @return list<uppercase-string>
106106
*/
107107
public static function all(): array
108108
{

system/Test/FeatureTestTrait.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use Closure;
1717
use CodeIgniter\Events\Events;
18+
use CodeIgniter\Exceptions\RuntimeException;
1819
use CodeIgniter\HTTP\Exceptions\RedirectException;
1920
use CodeIgniter\HTTP\IncomingRequest;
2021
use CodeIgniter\HTTP\Method;
@@ -76,11 +77,16 @@ protected function withRoutes(?array $routes = null)
7677
);
7778
}
7879

79-
/**
80-
* @TODO For backward compatibility. Remove strtolower() in the future.
81-
* @deprecated 4.5.0
82-
*/
83-
$method = strtolower($route[0]);
80+
// @todo v4.7.1 Remove the strtoupper() and use 'add' in v4.8.0
81+
if (! in_array(strtoupper($route[0]), ['ADD', 'CLI', ...Method::all()], true)) {
82+
throw new RuntimeException(sprintf(
83+
'Invalid HTTP method "%s" provided for route "%s".',
84+
$route[0],
85+
$route[1],
86+
));
87+
}
88+
89+
$method = strtolower($route[0]); // convert to method of RouteCollection
8490

8591
if (isset($route[3])) {
8692
$collection->{$method}($route[1], $route[2], $route[3]);

user_guide_src/source/changelogs/v4.7.1.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Bugs Fixed
5656
- **Session:** Fixed a bug in ``MemcachedHandler`` where the constructor incorrectly threw an exception when ``savePath`` was not empty.
5757
- **Toolbar:** Fixed a bug where the standalone toolbar page loaded from ``?debugbar_time=...`` was not interactive.
5858
- **Toolbar:** Fixed a bug in the Routes panel where only the first route parameter was converted to an input field on hover.
59+
- **Testing:** Fixed a bug in ``FeatureTestTrait::withRoutes()`` where invalid HTTP methods were not properly validated, thus passing them all to ``RouteCollection``.
5960
- **View:** Fixed a bug where ``View`` would throw an error if the ``appOverridesFolder`` config property was not defined.
6061

6162
See the repo's

0 commit comments

Comments
 (0)