mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-03 12:47:56 +02:00
[3.1.2] Add %Output.SortAttr to deal with FCKeditor bug
If %Output.SortAttr is true, attributes are sorted to be in alphabetical order. This was requested by frank farmer. See also: http://htmlpurifier.org/phorum/read.php?2,1576 Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user