From c7594487a259325b48bb17824bd733ab69793c0f Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Wed, 10 Jun 2009 18:24:52 -0400 Subject: [PATCH] Fix inability to totally override content model. Signed-off-by: Edward Z. Yang --- NEWS | 4 ++++ library/HTMLPurifier/ElementDef.php | 3 ++- tests/HTMLPurifier/ElementDefTest.php | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index fddb12e3..4b8cea81 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,9 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier # The allowed values for class have been relaxed to allow all of CDATA for doctypes that are not XHTML 1.1 or XHTML 2.0. For old behavior, set %Attr.ClassUseCDATA to false. +# Instead of appending the content model to an old content model, a blank + element will replace the old content model. You can use #SUPER to get + the old content model. ! More robust support for name="" and id="" ! HTMLPurifier_Config::inherit($config) allows you to inherit one configuration, and have changes to that configuration be propagated @@ -46,6 +49,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier - Fix bug where URIDefinition would not get cleared if it's directives got changed. - Fix fatal error in HTMLPurifier_Encoder on certain platforms (probably NetBSD 5.0) +- Fix bug in Linkify autoformatter involving http://foo . Created script maintenance/rename-config.php for renaming a configuration directive while maintaining its alias. This script does not change source code. . Implement namespace locking for definition construction, to prevent diff --git a/library/HTMLPurifier/ElementDef.php b/library/HTMLPurifier/ElementDef.php index b55c7bd7..aede2c3b 100644 --- a/library/HTMLPurifier/ElementDef.php +++ b/library/HTMLPurifier/ElementDef.php @@ -142,7 +142,8 @@ class HTMLPurifier_ElementDef $this->_mergeAssocArray($this->excludes, $def->excludes); if(!empty($def->content_model)) { - $this->content_model .= ' | ' . $def->content_model; + $this->content_model = + str_replace("#SUPER", $this->content_model, $def->content_model); $this->child = false; } if(!empty($def->content_model_type)) { diff --git a/tests/HTMLPurifier/ElementDefTest.php b/tests/HTMLPurifier/ElementDefTest.php index 60fb486e..500312b3 100644 --- a/tests/HTMLPurifier/ElementDefTest.php +++ b/tests/HTMLPurifier/ElementDefTest.php @@ -51,7 +51,7 @@ class HTMLPurifier_ElementDefTest extends HTMLPurifier_Harness 'removed-transform' => false, ); $def2->child = $new; - $def2->content_model = 'new'; + $def2->content_model = '#SUPER | new'; $def2->content_model_type = $overloaded_new; $def2->descendants_are_inline = true; $def2->excludes = array( -- 2.11.4.GIT