mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-01-03 05:11:52 +00:00
Make newline normalization optional.
This commit is contained in:
parent
632bf2bbd4
commit
9573f0933d
@ -6,7 +6,7 @@
|
|||||||
</file>
|
</file>
|
||||||
<file name="HTMLPurifier/Lexer.php">
|
<file name="HTMLPurifier/Lexer.php">
|
||||||
<line>81</line>
|
<line>81</line>
|
||||||
<line>282</line>
|
<line>284</line>
|
||||||
</file>
|
</file>
|
||||||
<file name="HTMLPurifier/Lexer/DirectLex.php">
|
<file name="HTMLPurifier/Lexer/DirectLex.php">
|
||||||
<line>53</line>
|
<line>53</line>
|
||||||
@ -154,7 +154,7 @@
|
|||||||
<line>202</line>
|
<line>202</line>
|
||||||
</file>
|
</file>
|
||||||
<file name="HTMLPurifier/Lexer.php">
|
<file name="HTMLPurifier/Lexer.php">
|
||||||
<line>269</line>
|
<line>271</line>
|
||||||
</file>
|
</file>
|
||||||
<file name="HTMLPurifier/HTMLModule/Image.php">
|
<file name="HTMLPurifier/HTMLModule/Image.php">
|
||||||
<line>27</line>
|
<line>27</line>
|
||||||
@ -214,14 +214,19 @@
|
|||||||
<line>48</line>
|
<line>48</line>
|
||||||
</file>
|
</file>
|
||||||
</directive>
|
</directive>
|
||||||
|
<directive id="HTML.NewlineNormalization">
|
||||||
|
<file name="HTMLPurifier/Lexer.php">
|
||||||
|
<line>266</line>
|
||||||
|
</file>
|
||||||
|
</directive>
|
||||||
<directive id="Core.ConvertDocumentToFragment">
|
<directive id="Core.ConvertDocumentToFragment">
|
||||||
<file name="HTMLPurifier/Lexer.php">
|
<file name="HTMLPurifier/Lexer.php">
|
||||||
<line>280</line>
|
<line>282</line>
|
||||||
</file>
|
</file>
|
||||||
</directive>
|
</directive>
|
||||||
<directive id="Core.RemoveProcessingInstructions">
|
<directive id="Core.RemoveProcessingInstructions">
|
||||||
<file name="HTMLPurifier/Lexer.php">
|
<file name="HTMLPurifier/Lexer.php">
|
||||||
<line>301</line>
|
<line>303</line>
|
||||||
</file>
|
</file>
|
||||||
</directive>
|
</directive>
|
||||||
<directive id="URI.">
|
<directive id="URI.">
|
||||||
|
@ -201,6 +201,7 @@ require 'HTMLPurifier/URIFilter/HostBlacklist.php';
|
|||||||
require 'HTMLPurifier/URIFilter/MakeAbsolute.php';
|
require 'HTMLPurifier/URIFilter/MakeAbsolute.php';
|
||||||
require 'HTMLPurifier/URIFilter/Munge.php';
|
require 'HTMLPurifier/URIFilter/Munge.php';
|
||||||
require 'HTMLPurifier/URIScheme/data.php';
|
require 'HTMLPurifier/URIScheme/data.php';
|
||||||
|
require 'HTMLPurifier/URIScheme/file.php';
|
||||||
require 'HTMLPurifier/URIScheme/ftp.php';
|
require 'HTMLPurifier/URIScheme/ftp.php';
|
||||||
require 'HTMLPurifier/URIScheme/http.php';
|
require 'HTMLPurifier/URIScheme/http.php';
|
||||||
require 'HTMLPurifier/URIScheme/https.php';
|
require 'HTMLPurifier/URIScheme/https.php';
|
||||||
|
@ -195,6 +195,7 @@ require_once $__dir . '/HTMLPurifier/URIFilter/HostBlacklist.php';
|
|||||||
require_once $__dir . '/HTMLPurifier/URIFilter/MakeAbsolute.php';
|
require_once $__dir . '/HTMLPurifier/URIFilter/MakeAbsolute.php';
|
||||||
require_once $__dir . '/HTMLPurifier/URIFilter/Munge.php';
|
require_once $__dir . '/HTMLPurifier/URIFilter/Munge.php';
|
||||||
require_once $__dir . '/HTMLPurifier/URIScheme/data.php';
|
require_once $__dir . '/HTMLPurifier/URIScheme/data.php';
|
||||||
|
require_once $__dir . '/HTMLPurifier/URIScheme/file.php';
|
||||||
require_once $__dir . '/HTMLPurifier/URIScheme/ftp.php';
|
require_once $__dir . '/HTMLPurifier/URIScheme/ftp.php';
|
||||||
require_once $__dir . '/HTMLPurifier/URIScheme/http.php';
|
require_once $__dir . '/HTMLPurifier/URIScheme/http.php';
|
||||||
require_once $__dir . '/HTMLPurifier/URIScheme/https.php';
|
require_once $__dir . '/HTMLPurifier/URIScheme/https.php';
|
||||||
|
Binary file not shown.
@ -0,0 +1,9 @@
|
|||||||
|
HTML.NewlineNormalization
|
||||||
|
TYPE: bool
|
||||||
|
VERSION: 4.2.0
|
||||||
|
DEFAULT: true
|
||||||
|
--DESCRIPTION--
|
||||||
|
<p>
|
||||||
|
Whether or not to normalize newlines.
|
||||||
|
</p>
|
||||||
|
--# vim: et sw=4 sts=4
|
@ -263,8 +263,10 @@ class HTMLPurifier_Lexer
|
|||||||
public function normalize($html, $config, $context) {
|
public function normalize($html, $config, $context) {
|
||||||
|
|
||||||
// normalize newlines to \n
|
// normalize newlines to \n
|
||||||
|
if ($config->get('HTML.NewlineNormalization')) {
|
||||||
$html = str_replace("\r\n", "\n", $html);
|
$html = str_replace("\r\n", "\n", $html);
|
||||||
$html = str_replace("\r", "\n", $html);
|
$html = str_replace("\r", "\n", $html);
|
||||||
|
}
|
||||||
|
|
||||||
if ($config->get('HTML.Trusted')) {
|
if ($config->get('HTML.Trusted')) {
|
||||||
// escape convoluted CDATA
|
// escape convoluted CDATA
|
||||||
|
@ -125,8 +125,6 @@ class HTML5 {
|
|||||||
const EOF = 5;
|
const EOF = 5;
|
||||||
|
|
||||||
public function __construct($data) {
|
public function __construct($data) {
|
||||||
$data = str_replace("\r\n", "\n", $data);
|
|
||||||
$data = str_replace("\r", null, $data);
|
|
||||||
|
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
$this->char = -1;
|
$this->char = -1;
|
||||||
|
@ -725,6 +725,24 @@ div {}
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_tokenizeHTML_removeNewline() {
|
||||||
|
$this->config->set('HTML.NewlineNormalization', true);
|
||||||
|
$input = "plain text\r\n";
|
||||||
|
$expect = array(
|
||||||
|
new HTMLPurifier_Token_Text("plain text\n")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_tokenizeHTML_noRemoveNewline() {
|
||||||
|
$this->config->set('HTML.NewlineNormalization', false);
|
||||||
|
$input = "plain text\r\n";
|
||||||
|
$expect = array(
|
||||||
|
new HTMLPurifier_Token_Text("plain text\r\n")
|
||||||
|
);
|
||||||
|
$this->assertTokenization($input, $expect);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
function test_tokenizeHTML_() {
|
function test_tokenizeHTML_() {
|
||||||
|
Loading…
Reference in New Issue
Block a user