From 733a5ce5c36f232fcc17df9071f4410362434fed Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Wed, 10 Jun 2009 18:11:34 -0400 Subject: [PATCH] Fix allowsElement() bug manifesting in LinkifyTest. Thanks frank farmer for reporting. Signed-off-by: Edward Z. Yang --- library/HTMLPurifier/Injector.php | 6 ++++++ tests/HTMLPurifier/Injector/LinkifyTest.php | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/library/HTMLPurifier/Injector.php b/library/HTMLPurifier/Injector.php index bc093b80..5922f813 100644 --- a/library/HTMLPurifier/Injector.php +++ b/library/HTMLPurifier/Injector.php @@ -137,6 +137,12 @@ abstract class HTMLPurifier_Injector if (!isset($parent->child->elements[$name]) || isset($parent->excludes[$name])) { return false; } + // check for exclusion + for ($i = count($this->currentNesting) - 2; $i >= 0; $i--) { + $node = $this->currentNesting[$i]; + $def = $this->htmlDefinition->info[$node->name]; + if (isset($def->excludes[$name])) return false; + } return true; } diff --git a/tests/HTMLPurifier/Injector/LinkifyTest.php b/tests/HTMLPurifier/Injector/LinkifyTest.php index e66f0eb9..1a1542d5 100644 --- a/tests/HTMLPurifier/Injector/LinkifyTest.php +++ b/tests/HTMLPurifier/Injector/LinkifyTest.php @@ -41,6 +41,10 @@ class HTMLPurifier_Injector_LinkifyTest extends HTMLPurifier_InjectorHarness $this->assertResult('http://example.com/'); } + function testExcludes() { + $this->assertResult('http://example.com'); + } + } // vim: et sw=4 sts=4 -- 2.11.4.GIT