Permalink
Browse files

Merge pull request #250 from sminnee/form-head-request-throws-500

Return 404 rather than 500 on bad actions in requesthandler
  • Loading branch information...
2 parents 673500c + 1d5065f commit 0ad6fe7ec1f8a65732a8c77d8f9ff64b1cffea5f @chillu chillu committed Mar 22, 2012
Showing with 4 additions and 2 deletions.
  1. +4 −1 control/RequestHandler.php
  2. +0 −1 forms/Form.php
@@ -162,12 +162,15 @@ function handleRequest(SS_HTTPRequest $request, DataModel $model) {
}
try {
+ if(!$this->hasMethod($action)) {
+ return $this->httpError(404, "Action '$action' isn't available on class " . get_class($this) . ".");
+ }
$result = $this->$action($request);
} catch(SS_HTTPResponse_Exception $responseException) {
$result = $responseException->getResponse();
}
} else {
- return $this->httpError(403, "Action '$action' isn't allowed on class $this->class");
+ return $this->httpError(403, "Action '$action' isn't allowed on class " . get_class($this) . ".");
}
if($result instanceof SS_HTTPResponse && $result->isError()) {
View
@@ -189,7 +189,6 @@ public function __construct($controller, $name, FieldList $fields, FieldList $ac
static $url_handlers = array(
'field/$FieldName!' => 'handleField',
- '$Action!' => 'handleAction',
'POST ' => 'httpSubmission',
'GET ' => 'httpSubmission',
'HEAD ' => 'httpSubmission',

0 comments on commit 0ad6fe7

Please sign in to comment.