diff --git a/NEWS b/NEWS index 2b7fe3fb..769d786d 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier to utilize full-screen mode. ! Add optional support for the file URI scheme, enable by explicitly setting %URI.AllowedSchemes. +! Add %Core.NormalizeNewlines options to allow turning off newline + normalization. - Fix improper handling of Internet Explorer conditional comments by parser. Thanks zmonteca for reporting. - Fix missing attributes bug when running on Mac Snow Leopard and APC. diff --git a/configdoc/usage.xml b/configdoc/usage.xml index b0944479..bd2f1a8a 100644 --- a/configdoc/usage.xml +++ b/configdoc/usage.xml @@ -109,10 +109,18 @@ 87 - + 101 + + 266 + + + + + 102 + @@ -214,11 +222,6 @@ 48 - - - 266 - - 282 diff --git a/library/HTMLPurifier/ConfigSchema/schema.ser b/library/HTMLPurifier/ConfigSchema/schema.ser index 528bd0de..978089c6 100644 Binary files a/library/HTMLPurifier/ConfigSchema/schema.ser and b/library/HTMLPurifier/ConfigSchema/schema.ser differ diff --git a/library/HTMLPurifier/ConfigSchema/schema/Core.NormalizeNewlines.txt b/library/HTMLPurifier/ConfigSchema/schema/Core.NormalizeNewlines.txt new file mode 100644 index 00000000..d77f5360 --- /dev/null +++ b/library/HTMLPurifier/ConfigSchema/schema/Core.NormalizeNewlines.txt @@ -0,0 +1,11 @@ +Core.NormalizeNewlines +TYPE: bool +VERSION: 4.2.0 +DEFAULT: true +--DESCRIPTION-- +

+ Whether or not to normalize newlines to the operating + system default. When false, HTML Purifier + will attempt to preserve mixed newline files. +

+--# vim: et sw=4 sts=4 diff --git a/library/HTMLPurifier/ConfigSchema/schema/HTML.NewlineNormalization.txt b/library/HTMLPurifier/ConfigSchema/schema/HTML.NewlineNormalization.txt deleted file mode 100644 index 948aea89..00000000 --- a/library/HTMLPurifier/ConfigSchema/schema/HTML.NewlineNormalization.txt +++ /dev/null @@ -1,9 +0,0 @@ -HTML.NewlineNormalization -TYPE: bool -VERSION: 4.2.0 -DEFAULT: true ---DESCRIPTION-- -

- Whether or not to normalize newlines. -

---# vim: et sw=4 sts=4 diff --git a/library/HTMLPurifier/Generator.php b/library/HTMLPurifier/Generator.php index f5310361..e6221db7 100644 --- a/library/HTMLPurifier/Generator.php +++ b/library/HTMLPurifier/Generator.php @@ -98,9 +98,11 @@ class HTMLPurifier_Generator } // Normalize newlines to system defined value - $nl = $this->config->get('Output.Newline'); - if ($nl === null) $nl = PHP_EOL; - if ($nl !== "\n") $html = str_replace("\n", $nl, $html); + if ($this->config->get('Core.NormalizeNewlines')) { + $nl = $this->config->get('Output.Newline'); + if ($nl === null) $nl = PHP_EOL; + if ($nl !== "\n") $html = str_replace("\n", $nl, $html); + } return $html; } diff --git a/library/HTMLPurifier/Lexer.php b/library/HTMLPurifier/Lexer.php index db14ebac..325d5c5f 100644 --- a/library/HTMLPurifier/Lexer.php +++ b/library/HTMLPurifier/Lexer.php @@ -263,7 +263,7 @@ class HTMLPurifier_Lexer public function normalize($html, $config, $context) { // normalize newlines to \n - if ($config->get('HTML.NewlineNormalization')) { + if ($config->get('Core.NormalizeNewlines')) { $html = str_replace("\r\n", "\n", $html); $html = str_replace("\r", "\n", $html); } diff --git a/tests/HTMLPurifier/LexerTest.php b/tests/HTMLPurifier/LexerTest.php index 79d1cf87..da582d15 100644 --- a/tests/HTMLPurifier/LexerTest.php +++ b/tests/HTMLPurifier/LexerTest.php @@ -726,18 +726,18 @@ div {} } function test_tokenizeHTML_removeNewline() { - $this->config->set('HTML.NewlineNormalization', true); - $input = "plain text\r\n"; + $this->config->set('Core.NormalizeNewlines', true); + $input = "plain\rtext\r\n"; $expect = array( - new HTMLPurifier_Token_Text("plain text\n") + new HTMLPurifier_Token_Text("plain\ntext\n") ); } function test_tokenizeHTML_noRemoveNewline() { - $this->config->set('HTML.NewlineNormalization', false); - $input = "plain text\r\n"; + $this->config->set('Core.NormalizeNewlines', false); + $input = "plain\rtext\r\n"; $expect = array( - new HTMLPurifier_Token_Text("plain text\r\n") + new HTMLPurifier_Token_Text("plain\rtext\r\n") ); $this->assertTokenization($input, $expect); }