mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX: URL input validation for RestfulServer
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@70376 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
6f8bd60def
commit
20e33bb6c3
@ -137,6 +137,11 @@ class RestfulServer extends Controller {
|
||||
$id = (isset($this->urlParams['ID'])) ? $this->urlParams['ID'] : null;
|
||||
$relation = (isset($this->urlParams['Relation'])) ? $this->urlParams['Relation'] : null;
|
||||
|
||||
// Check input formats
|
||||
if(!class_exists($className)) return $this->notFound();
|
||||
if($id && !is_numeric($id)) return $this->notFound();
|
||||
if($relation && !preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $relation)) return $this->notFound();
|
||||
|
||||
// if api access is disabled, don't proceed
|
||||
$apiAccess = singleton($className)->stat('api_access');
|
||||
if(!$apiAccess) return $this->permissionFailure();
|
||||
|
Loading…
x
Reference in New Issue
Block a user