SanitizeExtension.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. declare(strict_types=1);
  3. namespace PhpMyAdmin\Twig;
  4. use Twig\Extension\AbstractExtension;
  5. use Twig\TwigFilter;
  6. use Twig\TwigFunction;
  7. class SanitizeExtension extends AbstractExtension
  8. {
  9. /**
  10. * Returns a list of filters to add to the existing list.
  11. *
  12. * @return TwigFilter[]
  13. */
  14. public function getFilters()
  15. {
  16. return [
  17. new TwigFilter(
  18. 'escape_js_string',
  19. 'PhpMyAdmin\Sanitize::escapeJsString',
  20. ['is_safe' => ['html']]
  21. ),
  22. new TwigFilter(
  23. 'js_format',
  24. 'PhpMyAdmin\Sanitize::jsFormat',
  25. ['is_safe' => ['html']]
  26. ),
  27. new TwigFilter(
  28. 'sanitize',
  29. 'PhpMyAdmin\Sanitize::sanitizeMessage',
  30. ['is_safe' => ['html']]
  31. ),
  32. ];
  33. }
  34. /**
  35. * Returns a list of functions to add to the existing list.
  36. *
  37. * @return TwigFunction[]
  38. */
  39. public function getFunctions()
  40. {
  41. return [
  42. new TwigFunction(
  43. 'get_js_value',
  44. 'PhpMyAdmin\Sanitize::getJsValue',
  45. ['is_safe' => ['html']]
  46. ),
  47. ];
  48. }
  49. }