Skip to content

Commit

Permalink
Accept optional leading slash
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Nov 4, 2023
1 parent ae12ad1 commit 22ffba6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion application/core/LSHttpRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,6 @@ public static function routeMatchesNoCsrfValidationRule($route, $rule)
// For example the routes "rest" (in the case of "index.php/rest?...") or "rest/..." (in the case of
// "index.php/rest/...") should be matched by the rule "rest", but the route "admin/menus/sa/restore"
// should not.
return preg_match('#^' . $rule . '$|^' . $rule . '/#', (string) $route);
return preg_match('#/?(^' . $rule . '$)|(^' . $rule . '/)#', (string) $route);
}
}
1 change: 1 addition & 0 deletions tests/unit/CsrfHttpRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function testRemoteControlRoutesSkipCsrfValidation()
$routes = array(
'admin/remotecontrol/actionOnItemById/15',
'admin/remotecontrol/action',
'/admin/remotecontrol',
);

foreach ($routes as $route) {
Expand Down

0 comments on commit 22ffba6

Please sign in to comment.