diff --git a/library/HTMLPurifier/ElementDef.php b/library/HTMLPurifier/ElementDef.php
index 7c37d956..3a167ba4 100644
--- a/library/HTMLPurifier/ElementDef.php
+++ b/library/HTMLPurifier/ElementDef.php
@@ -93,7 +93,17 @@ class HTMLPurifier_ElementDef
function mergeIn($def) {
// later keys takes precedence
- foreach($def->attr as $k => $v) $this->attr[$k] = $v;
+ foreach($def->attr as $k => $v) {
+ if ($k == 0) {
+ // merge in the includes
+ // sorry, no way to override an include
+ foreach ($v as $v2) {
+ $def->attr[0][] = $v2;
+ }
+ continue;
+ }
+ $this->attr[$k] = $v;
+ }
foreach($def->attr_transform_pre as $k => $v) $this->attr_transform_pre[$k] = $v;
foreach($def->attr_transform_post as $k => $v) $this->attr_transform_post[$k] = $v;
foreach($def->auto_close as $k => $v) $this->auto_close[$k] = $v;
diff --git a/library/HTMLPurifier/HTMLDefinition.php b/library/HTMLPurifier/HTMLDefinition.php
index 21b8599e..7e7ac0b2 100644
--- a/library/HTMLPurifier/HTMLDefinition.php
+++ b/library/HTMLPurifier/HTMLDefinition.php
@@ -36,6 +36,7 @@ require_once 'HTMLPurifier/HTMLModule/StyleAttribute.php';
// compat modules
require_once 'HTMLPurifier/HTMLModule/TransformToStrict.php';
+require_once 'HTMLPurifier/HTMLModule/Legacy.php';
HTMLPurifier_ConfigSchema::define(
'HTML', 'EnableAttrID', false, 'bool',
@@ -256,6 +257,7 @@ class HTMLPurifier_HTMLDefinition
$this->modules['StyleAttribute']= new HTMLPurifier_HTMLModule_StyleAttribute();
$this->modules['TransformToStrict'] = new HTMLPurifier_HTMLModule_TransformToStrict($config);
+ if (!$this->strict) $this->modules['Legacy'] = new HTMLPurifier_HTMLModule_Legacy($config);
$this->attr_types = new HTMLPurifier_AttrTypes();
$this->attr_collections = new HTMLPurifier_AttrCollections();
@@ -393,42 +395,6 @@ class HTMLPurifier_HTMLDefinition
*/
function setupCompat($config) {
- // convenience for compat
- $e_Inline = new HTMLPurifier_ChildDef_Optional(
- $this->info_content_sets['Inline'] +
- array('#PCDATA' => true));
-
- // blockquote alt child def, implement in Legacy
- if (!$this->strict) {
- $this->info['blockquote']->child =
- new HTMLPurifier_ChildDef_Optional(
- $this->info_content_sets['Flow'] +
- array('#PCDATA' => true));
- }
-
- // deprecated element definitions, implement in Legacy
- if (!$this->strict) {
- $this->info['u'] =
- $this->info['s'] =
- $this->info['strike'] = new HTMLPurifier_ElementDef();
- $this->info['u']->child =
- $this->info['s']->child =
- $this->info['strike']->child = $e_Inline;
- $this->info['u']->descendants_are_inline =
- $this->info['s']->descendants_are_inline =
- $this->info['strike']->descendants_are_inline = true;
- }
-
- // changed content model for loose, implement in Legacy
- if ($this->strict) {
- $this->info['address']->child = $e_Inline;
- } else {
- $this->info['address']->child =
- new HTMLPurifier_ChildDef_Optional(
- $this->info_content_sets['Inline'] +
- array('#PCDATA' => true, 'p' => true));
- }
-
// deprecated config setting, implement in DisableURI module
if ($config->get('Attr', 'DisableURI')) {
$this->info['a']->attr['href'] =
@@ -440,12 +406,6 @@ class HTMLPurifier_HTMLDefinition
$this->info['img']->attr['src'] = null;
}
- // deprecated attributes implementations, implement in Legacy
- if (!$this->strict) {
- $this->info['li']->attr['value'] = new HTMLPurifier_AttrDef_Integer();
- $this->info['ol']->attr['start'] = new HTMLPurifier_AttrDef_Integer();
- }
-
// setup allowed elements, SubtractiveWhitelist module
$allowed_elements = $config->get('HTML', 'AllowedElements');
if (is_array($allowed_elements)) {
diff --git a/library/HTMLPurifier/HTMLModule/Legacy.php b/library/HTMLPurifier/HTMLModule/Legacy.php
index 92674cf7..0a7111ba 100644
--- a/library/HTMLPurifier/HTMLModule/Legacy.php
+++ b/library/HTMLPurifier/HTMLModule/Legacy.php
@@ -17,7 +17,40 @@
class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule
{
- // unimplemented
+ // incomplete
+
+ var $elements = array('u', 's', 'strike');
+ var $non_standalone_elements = array('li', 'ol', 'address', 'blockquote');
+
+ function HTMLPurifier_HTMLModule_Legacy() {
+ // setup new elements
+ foreach ($this->elements as $name) {
+ $this->info[$name] = new HTMLPurifier_ElementDef();
+ // for u, s, strike, as more elements get added, add
+ // conditionals as necessary
+ $this->info[$name]->content_model = 'Inline | #PCDATA';
+ $this->info[$name]->content_model_type = 'optional';
+ $this->info[$name]->attr[0] = array('Common');
+ }
+
+ // setup modifications to old elements
+ foreach ($this->non_standalone_elements as $name) {
+ $this->info[$name] = new HTMLPurifier_ElementDef();
+ $this->info[$name]->standalone = false;
+ }
+
+ $this->info['li']->attr['value'] = new HTMLPurifier_AttrDef_Integer();
+ $this->info['ol']->attr['start'] = new HTMLPurifier_AttrDef_Integer();
+
+ $this->info['address']->content_model = 'Inline | #PCDATA | p';
+ $this->info['address']->content_model_type = 'optional';
+ $this->info['address']->child = false;
+
+ $this->info['blockquote']->content_model = 'Flow | #PCDATA';
+ $this->info['blockquote']->content_model_type = 'optional';
+ $this->info['blockquote']->child = false;
+
+ }
}
diff --git a/tests/HTMLPurifier/Test.php b/tests/HTMLPurifier/Test.php
index daa39f53..3fa54173 100644
--- a/tests/HTMLPurifier/Test.php
+++ b/tests/HTMLPurifier/Test.php
@@ -83,6 +83,20 @@ class HTMLPurifier_Test extends UnitTestCase
}
+ function testEnableAttrID() {
+
+ $this->purifier = new HTMLPurifier();
+
+ $this->assertPurification(
+ 'foobar',
+ 'foobar'
+ );
+
+ $this->purifier = new HTMLPurifier(array('HTML.EnableAttrID' => true));
+ $this->assertPurification('foobar');
+
+ }
+
}
?>
\ No newline at end of file