Native.php 669 B

1234567891011121314151617181920212223242526
  1. <?php
  2. /**
  3. * This variable parser uses PHP's internal code engine. Because it does
  4. * this, it can represent all inputs; however, it is dangerous and cannot
  5. * be used by users.
  6. */
  7. class HTMLPurifier_VarParser_Native extends HTMLPurifier_VarParser
  8. {
  9. protected function parseImplementation($var, $type, $allow_null) {
  10. return $this->evalExpression($var);
  11. }
  12. protected function evalExpression($expr) {
  13. $var = null;
  14. $result = eval("\$var = $expr;");
  15. if ($result === false) {
  16. throw new HTMLPurifier_VarParserException("Fatal error in evaluated code");
  17. }
  18. return $var;
  19. }
  20. }
  21. // vim: et sw=4 sts=4