You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 satır
910B

  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. /**
  10. * @param mixed $var
  11. * @param int $type
  12. * @param bool $allow_null
  13. * @return null|string
  14. */
  15. protected function parseImplementation($var, $type, $allow_null)
  16. {
  17. return $this->evalExpression($var);
  18. }
  19. /**
  20. * @param string $expr
  21. * @return mixed
  22. * @throws HTMLPurifier_VarParserException
  23. */
  24. protected function evalExpression($expr)
  25. {
  26. $var = null;
  27. $result = eval("\$var = $expr;");
  28. if ($result === false) {
  29. throw new HTMLPurifier_VarParserException("Fatal error in evaluated code");
  30. }
  31. return $var;
  32. }
  33. }
  34. // vim: et sw=4 sts=4