/usr/share/php/Horde/Text/Filter/Cleanhtml.php is in php-horde-text-filter 2.3.3-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | <?php
/**
* Copyright 2009-2016 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @author Michael Slusarz <jan@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Text_Filter
*/
/**
* This filter attempts to sanitize HTML by cleaning up malformed HTML tags.
*
* Parameters:
* - body_only: (boolean) Only return the body data?
* DEFAULT: Return the whole HTML document
* - charset: (string) Charset of the data.
* DEFAULT: UTF-8
* - size: (integer) Only filter if data is below this size.
* DEFAULT: No default
*
* @author Michael Slusarz <jan@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Text_Filter
*/
class Horde_Text_Filter_Cleanhtml extends Horde_Text_Filter_Base
{
/**
* Filter parameters.
*
* @var array
*/
protected $_params = array(
'body_only' => false,
'charset' => 'UTF-8',
'size' => false
);
/**
* Executes any code necessary after applying the filter patterns.
*
* @param string $text The text after the filtering.
*
* @return string The modified text.
*/
public function postProcess($text)
{
if (!Horde_Util::extensionExists('tidy') ||
(($this->_params['size'] !== false) &&
(strlen($text) > $this->_params['size']))) {
return $text;
}
$tidy_config = array(
'enclose-block-text' => true,
'hide-comments' => true,
'indent' => false,
'numeric-entities' => true,
'preserve-entities' => true,
'show-body-only' => !empty($this->_params['body_only']),
'tab-size' => 0,
'wrap' => 0
);
$tidy = new tidy();
if (Horde_String::lower($this->_params['charset']) == 'us-ascii') {
if ($tidy->parseString($text, $tidy_config, 'ascii')) {
$tidy->cleanRepair();
$text = $tidy->value;
}
} elseif ($tidy->parseString(Horde_String::convertCharset($text, $this->_params['charset'], 'UTF-8'), $tidy_config, 'utf8')) {
$tidy->cleanRepair();
$text = Horde_String::convertCharset($tidy->value, 'UTF-8', $this->_params['charset']);
}
return $text;
}
}
|