mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-06 22:26:31 +02:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6bc04e0e10 | ||
|
24f6db6fb2 | ||
|
85fb192d93 |
2
NEWS
2
NEWS
@@ -12,6 +12,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
||||
3.2.0, unknown release date
|
||||
|
||||
3.1.2, unknown release date
|
||||
! %Output.AttrSort for when you need your attributes in alphabetical order to
|
||||
deal with a bug in FCKEditor. Requested by frank farmer.
|
||||
|
||||
3.1.1, released 2008-06-19
|
||||
# %URI.Munge now, by default, does not munge resources (for example, <img src="">)
|
||||
|
@@ -96,17 +96,22 @@
|
||||
</directive>
|
||||
<directive id="Output.CommentScriptContents">
|
||||
<file name="HTMLPurifier/Generator.php">
|
||||
<line>40</line>
|
||||
<line>45</line>
|
||||
</file>
|
||||
</directive>
|
||||
<directive id="Output.SortAttr">
|
||||
<file name="HTMLPurifier/Generator.php">
|
||||
<line>46</line>
|
||||
</file>
|
||||
</directive>
|
||||
<directive id="Output.TidyFormat">
|
||||
<file name="HTMLPurifier/Generator.php">
|
||||
<line>69</line>
|
||||
<line>75</line>
|
||||
</file>
|
||||
</directive>
|
||||
<directive id="Output.Newline">
|
||||
<file name="HTMLPurifier/Generator.php">
|
||||
<line>83</line>
|
||||
<line>89</line>
|
||||
</file>
|
||||
</directive>
|
||||
<directive id="HTML.BlockWrapper">
|
||||
|
@@ -118,9 +118,8 @@ there are now many character encodings floating around.</p>
|
||||
see a page on the web, chances are it's encoded in one
|
||||
of these encodings.</li>
|
||||
<li><strong>Unicode-based encodings</strong> implement the
|
||||
Unicode standard and include UTF-8, UCS-2 and UTF-16.
|
||||
They go beyond 8-bits (the first two are variable length,
|
||||
while the second one uses 16-bits), and support almost
|
||||
Unicode standard and include UTF-8, UTF-16 and UTF-32/UCS-4.
|
||||
They go beyond 8-bits and support almost
|
||||
every language in the world. UTF-8 is gaining traction
|
||||
as the dominant international encoding of the web.</li>
|
||||
</ul>
|
||||
|
File diff suppressed because one or more lines are too long
13
library/HTMLPurifier/ConfigSchema/schema/Output.SortAttr.txt
Normal file
13
library/HTMLPurifier/ConfigSchema/schema/Output.SortAttr.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
Output.SortAttr
|
||||
TYPE: bool
|
||||
VERSION: 3.1.2
|
||||
DEFAULT: false
|
||||
--DESCRIPTION--
|
||||
<p>
|
||||
If true, HTML Purifier will sort attributes by name before writing them back
|
||||
to the document, converting a tag like: <code><el b="" a="" c="" /></code>
|
||||
to <code><el a="" b="" c="" /></code>. This is a workaround for
|
||||
a bug in FCKeditor which causes it to swap attributes order, adding noise
|
||||
to text diffs. If you're not seeing this bug, chances are, you don't need
|
||||
this directive.
|
||||
</p>
|
@@ -26,6 +26,11 @@ class HTMLPurifier_Generator
|
||||
*/
|
||||
private $_def;
|
||||
|
||||
/**
|
||||
* Cache of %Output.SortAttr
|
||||
*/
|
||||
private $_sortAttr;
|
||||
|
||||
/**
|
||||
* Configuration for the generator
|
||||
*/
|
||||
@@ -38,6 +43,7 @@ class HTMLPurifier_Generator
|
||||
public function __construct($config, $context) {
|
||||
$this->config = $config;
|
||||
$this->_scriptFix = $config->get('Output', 'CommentScriptContents');
|
||||
$this->_sortAttr = $config->get('Output', 'SortAttr');
|
||||
$this->_def = $config->getHTMLDefinition();
|
||||
$this->_xhtml = $this->_def->doctype->xml;
|
||||
}
|
||||
@@ -142,6 +148,7 @@ class HTMLPurifier_Generator
|
||||
*/
|
||||
public function generateAttributes($assoc_array_of_attributes, $element = false) {
|
||||
$html = '';
|
||||
if ($this->_sortAttr) ksort($assoc_array_of_attributes);
|
||||
foreach ($assoc_array_of_attributes as $key => $value) {
|
||||
if (!$this->_xhtml) {
|
||||
// Remove namespaced attributes
|
||||
|
@@ -209,7 +209,6 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
}
|
||||
|
||||
function test_generateFromTokens_XHTMLoff() {
|
||||
$this->config = HTMLPurifier_Config::createDefault();
|
||||
$this->config->set('HTML', 'XHTML', false);
|
||||
|
||||
// omit trailing slash
|
||||
@@ -237,7 +236,6 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
// just don't test; Tidy is exploding on me.
|
||||
return;
|
||||
|
||||
$this->config = HTMLPurifier_Config::createDefault();
|
||||
$this->config->set('Core', 'TidyFormat', true);
|
||||
$this->config->set('Output', 'Newline', "\n");
|
||||
|
||||
@@ -253,5 +251,15 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
|
||||
|
||||
}
|
||||
|
||||
function test_generateFromTokens_sortAttr() {
|
||||
$this->config->set('Output', 'SortAttr', true);
|
||||
|
||||
$this->assertGeneration(
|
||||
array( new HTMLPurifier_Token_Start('p', array('b'=>'c', 'a'=>'d')) ),
|
||||
'<p a="d" b="c">'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user