diff options
| author | Bharat Mediratta <bharat@menalto.com> | 2009-09-03 11:25:02 -0700 | 
|---|---|---|
| committer | Bharat Mediratta <bharat@menalto.com> | 2009-09-03 11:25:02 -0700 | 
| commit | 82dd468002d5d21a5c8c391d6fce543b3df43de1 (patch) | |
| tree | 9e5efa8594d63999a083e087bb3debc6f657fcc8 /modules/gallery/libraries/SafeString.php | |
| parent | 53e2df01ebc26337fab13da2c38e6f2555a673d0 (diff) | |
Refactor interaction with the purifier module so that the API is
cleaner and we don't need to know about the module innards.  Move the
config file over there too.
Diffstat (limited to 'modules/gallery/libraries/SafeString.php')
| -rw-r--r-- | modules/gallery/libraries/SafeString.php | 28 | 
1 files changed, 8 insertions, 20 deletions
| diff --git a/modules/gallery/libraries/SafeString.php b/modules/gallery/libraries/SafeString.php index 93905572..3328fed5 100644 --- a/modules/gallery/libraries/SafeString.php +++ b/modules/gallery/libraries/SafeString.php @@ -26,8 +26,6 @@ class SafeString_Core {    protected $_is_safe_html = false;    protected $_is_purified_html = false; -  private static $_purifier = null; -    /** Constructor */    function __construct($string) {      if ($string instanceof SafeString) { @@ -151,29 +149,19 @@ class SafeString_Core {      return $this->_raw_string;    } -  // Escapes special HTML chars ("<", ">", "&", etc.) to HTML entities. +  /** +   * Escape special HTML chars ("<", ">", "&", etc.) to HTML entities. +   */    private static function _escape_for_html($dirty_html) {      return html::specialchars($dirty_html);    } -  // Purifies the string, removing any potentially malicious or unsafe HTML / JavaScript. +  /** +   * Purify the string, removing any potentially malicious or unsafe HTML / JavaScript. +   */    private static function _purify_for_html($dirty_html) { -    if (null === self::$_purifier) { -      if (module::is_active("htmlpurifier")) { -        require_once(MODPATH . "htmlpurifier/lib/HTMLPurifier/HTMLPurifier.auto.php"); -        $config = HTMLPurifier_Config::createDefault(); -        foreach (Kohana::config('purifier') as $category => $key_value) { -          foreach ($key_value as $key => $value) { -            $config->set("$category.$key", $value); -          } -        } -        self::$_purifier = new HTMLPurifier($config); -      } else { -        self::$_purifier = false; -      } -    } -    if (self::$_purifier) { -      return self::$_purifier->purify($dirty_html); +    if (method_exists("purifier", "purify")) { +      return purifier::purify($dirty_html);      } else {        return self::_escape_for_html($dirty_html);      } | 
