Example #1
0
 public static function purifyHTML($html)
 {
     static $use_html_purifier = null;
     static $purifier = null;
     if (defined('PS_INSTALLATION_IN_PROGRESS') || !Configuration::configurationIsLoaded()) {
         return $html;
     }
     if ($use_html_purifier === null) {
         $use_html_purifier = (bool) Configuration::get('PS_USE_HTMLPURIFIER');
     }
     if ($use_html_purifier) {
         $config = HTMLPurifier_Config::createDefault();
         $config->set('Attr.EnableID', true);
         $config->set('Cache.SerializerPath', _PS_CACHE_DIR_ . 'purifier');
         if (Configuration::get('PS_ALLOW_HTML_IFRAME')) {
             $config->set('HTML.SafeIframe', true);
             $config->set('HTML.SafeObject', true);
             $config->set('URI.SafeIframeRegexp', '/.*/');
         }
         $purifier = new HTMLPurifier($config);
         $html = $purifier->purify($html);
     }
     return $html;
 }
 public static function purifyHTML($html)
 {
     static $use_html_purifier = null;
     static $purifier = null;
     if (defined('PS_INSTALLATION_IN_PROGRESS') || !Configuration::configurationIsLoaded()) {
         return $html;
     }
     if ($use_html_purifier === null) {
         $use_html_purifier = (bool) Configuration::get('PS_USE_HTMLPURIFIER');
     }
     if ($use_html_purifier) {
         if ($purifier === null) {
             $config = HTMLPurifier_Config::createDefault();
             $config->set('Attr.EnableID', true);
             $config->set('HTML.Trusted', true);
             $config->set('Cache.SerializerPath', _PS_CACHE_DIR_ . 'purifier');
             $config->set('Attr.AllowedFrameTargets', array('_blank', '_self', '_parent', '_top'));
             if (Configuration::get('PS_ALLOW_HTML_IFRAME')) {
                 $config->set('HTML.SafeIframe', true);
                 $config->set('HTML.SafeObject', true);
                 $config->set('URI.SafeIframeRegexp', '/.*/');
             }
             $purifier = new HTMLPurifier($config);
         }
         if (_PS_MAGIC_QUOTES_GPC_) {
             $html = stripslashes($html);
         }
         $html = $purifier->purify($html);
         if (_PS_MAGIC_QUOTES_GPC_) {
             $html = addslashes($html);
         }
     }
     return $html;
 }
Example #3
0
 public static function purifyHTML($html)
 {
     static $use_html_purifier = null;
     static $purifier = null;
     if (defined('PS_INSTALLATION_IN_PROGRESS') || !Configuration::configurationIsLoaded()) {
         return $html;
     }
     if ($use_html_purifier === null) {
         $use_html_purifier = (bool) Configuration::get('PS_USE_HTMLPURIFIER');
     }
     if ($use_html_purifier) {
         if ($purifier === null) {
             $config = HTMLPurifier_Config::createDefault();
             // Set some HTML5 properties
             $config->set('HTML.DefinitionID', 'html5-definitions');
             // unqiue id
             $config->set('HTML.DefinitionRev', 1);
             $config->set('Attr.EnableID', true);
             $config->set('HTML.Trusted', true);
             $config->set('Cache.SerializerPath', _PS_CACHE_DIR_ . 'purifier');
             $config->set('Attr.AllowedFrameTargets', array('_blank', '_self', '_parent', '_top'));
             if (Configuration::get('PS_ALLOW_HTML_IFRAME')) {
                 $config->set('HTML.SafeIframe', true);
                 $config->set('HTML.SafeObject', true);
                 $config->set('URI.SafeIframeRegexp', '/.*/');
             }
             // http://developers.whatwg.org/the-video-element.html#the-video-element
             if ($def = $config->maybeGetRawHTMLDefinition()) {
                 $def->addElement('video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', array('src' => 'URI', 'type' => 'Text', 'width' => 'Length', 'height' => 'Length', 'poster' => 'URI', 'preload' => 'Enum#auto,metadata,none', 'controls' => 'Bool'));
                 $def->addElement('source', 'Block', 'Flow', 'Common', array('src' => 'URI', 'type' => 'Text'));
             }
             $purifier = new HTMLPurifier($config);
         }
         if (_PS_MAGIC_QUOTES_GPC_) {
             $html = stripslashes($html);
         }
         $html = $purifier->purify($html);
         if (_PS_MAGIC_QUOTES_GPC_) {
             $html = addslashes($html);
         }
     }
     return $html;
 }
Example #4
0
 public static function purifyHTML($html, $uri_unescape = null, $allow_style = false)
 {
     require_once _PS_TOOL_DIR_ . 'htmlpurifier/HTMLPurifier.standalone.php';
     static $use_html_purifier = null;
     static $purifier = null;
     if (defined('PS_INSTALLATION_IN_PROGRESS') || !Configuration::configurationIsLoaded()) {
         return $html;
     }
     if ($use_html_purifier === null) {
         $use_html_purifier = (bool) Configuration::get('PS_USE_HTMLPURIFIER');
     }
     if ($use_html_purifier) {
         if ($purifier === null) {
             $config = HTMLPurifier_Config::createDefault();
             $config->set('Attr.EnableID', true);
             $config->set('HTML.Trusted', true);
             $config->set('Cache.SerializerPath', _PS_CACHE_DIR_ . 'purifier');
             $config->set('Attr.AllowedFrameTargets', array('_blank', '_self', '_parent', '_top'));
             if (is_array($uri_unescape)) {
                 $config->set('URI.UnescapeCharacters', implode('', $uri_unescape));
             }
             if (Configuration::get('PS_ALLOW_HTML_IFRAME')) {
                 $config->set('HTML.SafeIframe', true);
                 $config->set('HTML.SafeObject', true);
                 $config->set('URI.SafeIframeRegexp', '/.*/');
             }
             /** @var HTMLPurifier_HTMLDefinition|HTMLPurifier_HTMLModule $def */
             // http://developers.whatwg.org/the-video-element.html#the-video-element
             if ($def = $config->getHTMLDefinition(true)) {
                 $def->addElement('video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', array('src' => 'URI', 'type' => 'Text', 'width' => 'Length', 'height' => 'Length', 'poster' => 'URI', 'preload' => 'Enum#auto,metadata,none', 'controls' => 'Bool'));
                 $def->addElement('source', 'Block', 'Flow', 'Common', array('src' => 'URI', 'type' => 'Text'));
                 if ($allow_style) {
                     $def->addElement('style', 'Block', 'Flow', 'Common', array('type' => 'Text'));
                 }
             }
             $purifier = new HTMLPurifier($config);
         }
         if (_PS_MAGIC_QUOTES_GPC_) {
             $html = stripslashes($html);
         }
         $html = $purifier->purify($html);
         if (_PS_MAGIC_QUOTES_GPC_) {
             $html = addslashes($html);
         }
     }
     return $html;
 }