BaseHtmlPurifier.php 918 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2008 Yii Software LLC
  4. * @link http://www.yiiframework.com/
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\helpers;
  8. /**
  9. * BaseHtmlPurifier provides concrete implementation for [[HtmlPurifier]].
  10. *
  11. * Do not use BaseHtmlPurifier. Use [[HtmlPurifier]] instead.
  12. *
  13. * @author Alexander Makarov <[email protected]>
  14. * @since 2.0
  15. */
  16. class BaseHtmlPurifier
  17. {
  18. /**
  19. * Passes markup through HTMLPurifier making it safe to output to end user
  20. *
  21. * @param string $content
  22. * @param array|null $config
  23. * @return string
  24. */
  25. public static function process($content, $config = null)
  26. {
  27. $configInstance = \HTMLPurifier_Config::create($config);
  28. $configInstance->autoFinalize = false;
  29. $purifier=\HTMLPurifier::instance($configInstance);
  30. $purifier->config->set('Cache.SerializerPath', \Yii::$app->getRuntimePath());
  31. return $purifier->purify($content);
  32. }
  33. }