mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-13 10:46:17 +02:00
[2.1.4] [MFH] addAttribute() can be called multiple times, from r1634
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/branches/php4@1717 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
7
NEWS
7
NEWS
@ -9,6 +9,11 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
|||||||
. Internal change
|
. Internal change
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
|
ERRATA
|
||||||
|
- PH5P is seriously broken here; it can result in fatal errors and exceptions.
|
||||||
|
If you desire to use it, please use it with the latest, PHP5-only version of
|
||||||
|
HTML Purifier.
|
||||||
|
|
||||||
2.1.4, unknown release date
|
2.1.4, unknown release date
|
||||||
! DefinitionCacheFactory now can register new implementations
|
! DefinitionCacheFactory now can register new implementations
|
||||||
! CSS properties are now case-insensitive
|
! CSS properties are now case-insensitive
|
||||||
@ -19,6 +24,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
|||||||
- Fix bug with trusted script handling in libxml versions later than 2.6.28.
|
- Fix bug with trusted script handling in libxml versions later than 2.6.28.
|
||||||
- Fix bug in comment parsing with DirectLex
|
- Fix bug in comment parsing with DirectLex
|
||||||
- Fix bug with rgb(0, 1, 2) color syntax with spaces inside shorthand syntax
|
- Fix bug with rgb(0, 1, 2) color syntax with spaces inside shorthand syntax
|
||||||
|
- HTMLPurifier_HTMLDefinition->addAttribute can now be called multiple times
|
||||||
|
on the same element without emitting errors.
|
||||||
|
|
||||||
2.1.3, released 2007-11-05
|
2.1.3, released 2007-11-05
|
||||||
! tests/multitest.php allows you to test multiple versions by running
|
! tests/multitest.php allows you to test multiple versions by running
|
||||||
|
@ -222,6 +222,8 @@ class HTMLPurifier_HTMLDefinition extends HTMLPurifier_Definition
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a custom attribute to a pre-existing element
|
* Adds a custom attribute to a pre-existing element
|
||||||
|
* @note This is strictly convenience, and does not have a corresponding
|
||||||
|
* method in HTMLPurifier_HTMLModule
|
||||||
* @param $element_name String element name to add attribute to
|
* @param $element_name String element name to add attribute to
|
||||||
* @param $attr_name String name of attribute
|
* @param $attr_name String name of attribute
|
||||||
* @param $def Attribute definition, can be string or object, see
|
* @param $def Attribute definition, can be string or object, see
|
||||||
@ -229,7 +231,11 @@ class HTMLPurifier_HTMLDefinition extends HTMLPurifier_Definition
|
|||||||
*/
|
*/
|
||||||
function addAttribute($element_name, $attr_name, $def) {
|
function addAttribute($element_name, $attr_name, $def) {
|
||||||
$module =& $this->getAnonymousModule();
|
$module =& $this->getAnonymousModule();
|
||||||
$element =& $module->addBlankElement($element_name);
|
if (!isset($module->info[$element_name])) {
|
||||||
|
$element =& $module->addBlankElement($element_name);
|
||||||
|
} else {
|
||||||
|
$element =& $module->info[$element_name];
|
||||||
|
}
|
||||||
$element->attr[$attr_name] = $def;
|
$element->attr[$attr_name] = $def;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,6 +87,22 @@ a[href|title]
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_addAttribute_multiple() {
|
||||||
|
|
||||||
|
$config = HTMLPurifier_Config::create(array(
|
||||||
|
'HTML.DefinitionID' => 'HTMLPurifier_HTMLDefinitionTest->test_addAttribute_multiple'
|
||||||
|
));
|
||||||
|
$def =& $config->getHTMLDefinition(true);
|
||||||
|
$def->addAttribute('span', 'custom', 'Enum#attribute');
|
||||||
|
$def->addAttribute('span', 'foo', 'Text');
|
||||||
|
|
||||||
|
$purifier = new HTMLPurifier($config);
|
||||||
|
$input = '<span custom="attribute" foo="asdf">Custom!</span>';
|
||||||
|
$output = $purifier->purify($input);
|
||||||
|
$this->assertIdentical($input, $output);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function test_addElement() {
|
function test_addElement() {
|
||||||
|
|
||||||
$config = HTMLPurifier_Config::create(array(
|
$config = HTMLPurifier_Config::create(array(
|
||||||
|
Reference in New Issue
Block a user