mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-30 19:00:10 +02:00
Implement native VarParser.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1604 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
25
library/HTMLPurifier/VarParser/Native.php
Normal file
25
library/HTMLPurifier/VarParser/Native.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This variable parser uses PHP's internal code engine. Because it does
|
||||
* this, it can represent all inputs; however, it is dangerous and cannot
|
||||
* be used by users.
|
||||
*/
|
||||
class HTMLPurifier_VarParser_Native extends HTMLPurifier_VarParser
|
||||
{
|
||||
|
||||
protected function parseImplementation($var, $type, $allow_null) {
|
||||
return $this->evalExpression($var);
|
||||
}
|
||||
|
||||
protected function evalExpression($expr) {
|
||||
$var = null;
|
||||
$result = eval("\$var = $expr;");
|
||||
if ($result === false) {
|
||||
throw new HTMLPurifier_VarParserException("Fatal error in evaluated code");
|
||||
}
|
||||
return $var;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user