diff --git a/library/HTMLPurifier/Injector/Linkify.php b/library/HTMLPurifier/Injector/Linkify.php index 19be2152..9ef162f0 100644 --- a/library/HTMLPurifier/Injector/Linkify.php +++ b/library/HTMLPurifier/Injector/Linkify.php @@ -19,7 +19,7 @@ class HTMLPurifier_Injector_Linkify extends HTMLPurifier_Injector } else { $parent = $definition->info_parent_def; } - if (!isset($parent->child->elements['a'])) { + if (!isset($parent->child->elements['a']) || isset($parent->excludes['a'])) { // parent element does not allow link elements, don't bother return; } @@ -29,8 +29,8 @@ class HTMLPurifier_Injector_Linkify extends HTMLPurifier_Injector // "google.com" return; } - // there is/are URL(s). Let's split the string: + // there is/are URL(s). Let's split the string: $bits = preg_split('#((?:https?|ftp)://[^\s\'"<>()]+)#S', $token->data, -1, PREG_SPLIT_DELIM_CAPTURE); $token = array(); diff --git a/library/HTMLPurifier/Strategy/MakeWellFormed.php b/library/HTMLPurifier/Strategy/MakeWellFormed.php index abd3cf67..ee989a3e 100644 --- a/library/HTMLPurifier/Strategy/MakeWellFormed.php +++ b/library/HTMLPurifier/Strategy/MakeWellFormed.php @@ -256,8 +256,9 @@ class HTMLPurifier_Strategy_MakeWellFormed extends HTMLPurifier_Strategy $injector =& $context->get('Injector'); $current_injector =& $context->get('CurrentInjector'); - if (isset($injector[$current_injector])) { - $injector_skip[$current_injector] = count($token); + $offset = count($token); + for ($i = 0; $i <= $current_injector; $i++) { + $injector_skip[$i] += $offset; } } elseif ($token) { diff --git a/tests/Debugger.php b/tests/Debugger.php index 2ef5ba8e..5438197c 100644 --- a/tests/Debugger.php +++ b/tests/Debugger.php @@ -54,6 +54,19 @@ function isInScopes($array = array()) { } /**#@-*/ +function printTokens($tokens, $index) { + $string = '
';
+    $generator = new HTMLPurifier_Generator();
+    foreach ($tokens as $i => $token) {
+        if ($index == $i) $string .= '[';
+        $string .= "$i";
+        $string .= $generator->escape($generator->generateFromToken($token));
+        if ($index == $i) $string .= ']';
+    }
+    $string .= '
'; + echo $string; +} + /** * The debugging singleton. Most interesting stuff happens here. */ diff --git a/tests/HTMLPurifier/Strategy/MakeWellFormedTest.php b/tests/HTMLPurifier/Strategy/MakeWellFormedTest.php index 5a6d4e7a..5991ebb7 100644 --- a/tests/HTMLPurifier/Strategy/MakeWellFormedTest.php +++ b/tests/HTMLPurifier/Strategy/MakeWellFormedTest.php @@ -196,6 +196,10 @@ Par 'This URL http://example.com is what you need' ); + $this->assertResult( + 'http://example.com/' + ); + } function testMultipleInjectors() {