htmlpurify MDL-22654 Implemented solution to fix issues rising from HTML purify normalising line breaks

This commit is contained in:
Sam Hemelryk 2010-06-03 03:34:05 +00:00
parent 4ad6e3f475
commit 8ac11ff286
3 changed files with 6 additions and 2 deletions

View File

@ -252,8 +252,10 @@ class HTMLPurifier_Lexer
public function normalize($html, $config, $context) {
// normalize newlines to \n
$html = str_replace("\r\n", "\n", $html);
$html = str_replace("\r", "\n", $html);
if ($config->get('Output.Newline')!=="\n") {
$html = str_replace("\r\n", "\n", $html);
$html = str_replace("\r", "\n", $html);
}
if ($config->get('HTML.Trusted')) {
// escape convoluted CDATA

View File

@ -4,5 +4,6 @@ Changes:
* HMLTModule/Text.php - added <nolink>, <tex>, <lang> and <algebra> tags
* HMLTModule/XMLCommonAttributes.php - remove xml:lang - needed for multilang
* AttrDef/Lang.php - relax lang check - needed for multilang
* Lexer.php - Subverted line break normalisation (requires setting: Output.Newline to \n)
skodak

View File

@ -1496,6 +1496,7 @@ function purify_html($text) {
if ($purifier === false) {
require_once $CFG->libdir.'/htmlpurifier/HTMLPurifier.safe-includes.php';
$config = HTMLPurifier_Config::createDefault();
$config->set('Output.Newline', "\n");
$config->set('Core.ConvertDocumentToFragment', true);
$config->set('Core.Encoding', 'UTF-8');
$config->set('HTML.Doctype', 'XHTML 1.0 Transitional');