diff --git a/library/HTMLPurifier/IDAccumulator.php b/library/HTMLPurifier/IDAccumulator.php new file mode 100644 index 00000000..a90f93f7 --- /dev/null +++ b/library/HTMLPurifier/IDAccumulator.php @@ -0,0 +1,27 @@ +ids[$id])) return false; + return $this->ids[$id] = true; + } + + function reset() { + $this->ids = array(); + } + +} + +?> \ No newline at end of file diff --git a/tests/HTMLPurifier/IDAccumulatorTest.php b/tests/HTMLPurifier/IDAccumulatorTest.php new file mode 100644 index 00000000..377e973e --- /dev/null +++ b/tests/HTMLPurifier/IDAccumulatorTest.php @@ -0,0 +1,26 @@ +reset(); + + $this->assertTrue( $accumulator->add('id1')); + $this->assertTrue( $accumulator->add('id2')); + $this->assertFalse($accumulator->add('id1')); // repeated id + $accumulator->reset(); + + $this->assertTrue( $accumulator->add('id2')); // test reset + $accumulator->reset(); + + } + +} + +?> \ No newline at end of file diff --git a/tests/index.php b/tests/index.php index 5cb61927..05ec1b4a 100644 --- a/tests/index.php +++ b/tests/index.php @@ -33,6 +33,7 @@ $test->addTestFile('HTMLPurifier/Strategy/FixNestingTest.php'); $test->addTestFile('HTMLPurifier/Strategy/CompositeTest.php'); $test->addTestFile('HTMLPurifier/Strategy/CoreTest.php'); $test->addTestFile('HTMLPurifier/AttrDef/EnumTest.php'); +$test->addTestFile('HTMLPurifier/IDAccumulatorTest.php'); $test->run( new HtmlReporter() );