. // All rights reserved. // // HTML Sanitizer is free software; you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // HTML Sanitizer is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with HTML Sanitizer; if not, see . // // ***** END LICENSE BLOCK *****. /** * Sanitize HTML contents : * Remove dangerous tags and attributes that can lead to security issues like * XSS or HTTP response splitting. * * @author Frederic Minne * @copyright Copyright © 2005-2011, Frederic Minne * @license http://www.gnu.org/licenses/lgpl.txt GNU Lesser General Public License version 3 or later * @version 1.1 */ class HTML_Sanitizer { /** * Private fields. */ private $_allowedTags; private $_allowJavascriptEvents; private $_allowJavascriptInUrls; private $_allowObjects; private $_allowScript; private $_allowStyle; private $_additionalTags; /** * Constructor. */ public function __construct() { $this->resetAll(); } /** * (re)set all options to default value. */ public function resetAll() { $this->_allowDOMEvents = FALSE; $this->_allowJavascriptInUrls = FALSE; $this->_allowStyle = FALSE; $this->_allowScript = FALSE; $this->_allowObjects = FALSE; $this->_allowStyle = FALSE; $this->_allowedTags = '

' . '
    1. ' . '

      ' . '

        ' . ''; $this->_additionalTags = ''; } /** * Add additional tags to allowed tags. * * @param string * * @access public */ public function addAdditionalTags($tags) { $this->_additionalTags .= $tags; } /** * Allow iframes. * * @access public */ public function allowIframes() { $this->addAdditionalTags('