From f7806129f502c772d447373052fcb4af6153cdbd Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Thu, 11 Sep 2008 00:15:31 +0000 Subject: [PATCH] Made allowed_actions case insensitive git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@62213 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/control/RequestHandlingData.php | 5 +++++ tests/RequestHandlingTest.php | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/core/control/RequestHandlingData.php b/core/control/RequestHandlingData.php index 00ffc1aab..5c0248f5f 100644 --- a/core/control/RequestHandlingData.php +++ b/core/control/RequestHandlingData.php @@ -165,6 +165,11 @@ class RequestHandlingData extends ViewableData { if($action == 'index') return true; + // Make checkAccessAction case-insensitive + $action = strtolower($action); + foreach($access as $k => $v) $newAccess[strtolower($k)] = strtolower($v); + $access = $newAccess; + if(isset($access[$action])) { $test = $access[$action]; if($test === true) return true; diff --git a/tests/RequestHandlingTest.php b/tests/RequestHandlingTest.php index a6d7a533f..14bde7282 100644 --- a/tests/RequestHandlingTest.php +++ b/tests/RequestHandlingTest.php @@ -115,6 +115,13 @@ class RequestHandlingTest_Form extends Form { "GET " => "handleGet", ); + // These are a different case from those in url_handlers to confirm that it's all case-insensitive + static $allowed_actions = array( + 'handlesubmission', + 'handlefield', + 'handleget', + ); + function handleField($request) { return $this->dataFieldByName($request->param('FieldName')); } @@ -138,6 +145,13 @@ class RequestHandlingTest_FormField extends FormField { '' => 'handleField', '$Action' => '$Action', ); + + // These contain uppercase letters to test that allowed_actions doesn't need to be all lowercase + static $allowed_actions = array( + 'TEST', + 'handleField', + 'handleInPLACEEDIT', + ); function test() { return "Test method on $this->name";