-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #2176 Improved Sandbox error handling (kitbs)
This PR was squashed before being merged into the 1.x branch (closes #2176). Discussion ---------- Improved Sandbox error handling On the model of the SecurityNotAllowedFilterError, SecurityNotAllowedFunctionError and SecurityNotAllowedTagError, I added SecurityNotAllowedMethodError and SecurityNotAllowedPropertyError to allow the user to retrieve both the $className and $methodName/$propertyName from the exception. Commits ------- e1c980f Improved Sandbox error handling
- Loading branch information
Showing
5 changed files
with
146 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Twig. | ||
* | ||
* (c) 2009 Fabien Potencier | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
/** | ||
* Exception thrown when a not allowed class method is used in a template. | ||
* | ||
* @author Kit Burton-Senior <mail@kitbs.com> | ||
*/ | ||
class Twig_Sandbox_SecurityNotAllowedMethodError extends Twig_Sandbox_SecurityError | ||
{ | ||
private $className; | ||
private $methodName; | ||
|
||
public function __construct($message, $className, $methodName, $lineno = -1, $filename = null, Exception $previous = null) | ||
{ | ||
parent::__construct($message, $lineno, $filename, $previous); | ||
$this->className = $className; | ||
$this->methodName = $methodName; | ||
} | ||
|
||
public function getClassName() | ||
{ | ||
return $this->className; | ||
} | ||
|
||
public function getMethodName() | ||
{ | ||
return $this->methodName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Twig. | ||
* | ||
* (c) 2009 Fabien Potencier | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
/** | ||
* Exception thrown when a not allowed class property is used in a template. | ||
* | ||
* @author Kit Burton-Senior <mail@kitbs.com> | ||
*/ | ||
class Twig_Sandbox_SecurityNotAllowedPropertyError extends Twig_Sandbox_SecurityError | ||
{ | ||
private $className; | ||
private $propertyName; | ||
|
||
public function __construct($message, $className, $propertyName, $lineno = -1, $filename = null, Exception $previous = null) | ||
{ | ||
parent::__construct($message, $lineno, $filename, $previous); | ||
$this->className = $className; | ||
$this->propertyName = $propertyName; | ||
} | ||
|
||
public function getClassName() | ||
{ | ||
return $this->className; | ||
} | ||
|
||
public function getPropertyName() | ||
{ | ||
return $this->propertyName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters