1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-06 14:16:32 +02:00

Use a Zipper to process MakeWellFormed, removing quadratic behavior.

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
Edward Z. Yang
2013-10-13 12:53:51 -07:00
parent 82bcc62058
commit 8f401f769e
10 changed files with 158 additions and 149 deletions

View File

@@ -24,7 +24,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_EndRewindInjector extends HTMLPurifie
) {
$token = false;
$prev->_InjectorTest_EndRewindInjector_delete = true;
$this->rewind($i);
$this->rewindOffset(1);
}
}
}

View File

@@ -27,7 +27,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_Str
$i->start->skip = array(0 => true, 1 => true);
$mock->expectAt(1, 'handleEnd', array($i));
$mock->expectCallCount('handleEnd', 2);
$mock->setReturnValue('getRewind', false);
$mock->setReturnValue('getRewindOffset', false);
$this->config->set('AutoFormat.AutoParagraph', false);
$this->config->set('AutoFormat.Linkify', false);
$this->config->set('AutoFormat.Custom', array($mock));

View File

@@ -16,7 +16,8 @@ class HTMLPurifier_ZipperTest extends HTMLPurifier_Harness
$z->insertBefore(4);
$z->insertAfter(5);
$this->assertIdentical($z->toArray($t), array(0,1,4,3,5));
$t = $z->splice($t, 2, array(6,7));
list($old, $t) = $z->splice($t, 2, array(6,7));
$this->assertIdentical($old, array(3,5));
$this->assertIdentical($t, 6);
$this->assertIdentical($z->toArray($t), array(0,1,4,6,7));
}