From 7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 12 May 2012 17:57:41 -0700 Subject: some important stuff we'll need --- .../Strategy/RemoveForeignElementsTest.php | 115 +++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 lib/htmlpurifier/tests/HTMLPurifier/Strategy/RemoveForeignElementsTest.php (limited to 'lib/htmlpurifier/tests/HTMLPurifier/Strategy/RemoveForeignElementsTest.php') diff --git a/lib/htmlpurifier/tests/HTMLPurifier/Strategy/RemoveForeignElementsTest.php b/lib/htmlpurifier/tests/HTMLPurifier/Strategy/RemoveForeignElementsTest.php new file mode 100644 index 000000000..b3ca1646a --- /dev/null +++ b/lib/htmlpurifier/tests/HTMLPurifier/Strategy/RemoveForeignElementsTest.php @@ -0,0 +1,115 @@ +obj = new HTMLPurifier_Strategy_RemoveForeignElements(); + } + + function testBlankInput() { + $this->assertResult(''); + } + + function testPreserveRecognizedElements() { + $this->assertResult('This is bold text.'); + } + + function testRemoveForeignElements() { + $this->assertResult( + 'BlingBong', + 'BlingBong' + ); + } + + function testRemoveScriptAndContents() { + $this->assertResult( + '', + '' + ); + } + + function testRemoveStyleAndContents() { + $this->assertResult( + '', + '' + ); + } + + function testRemoveOnlyScriptTagsLegacy() { + $this->config->set('Core.RemoveScriptContents', false); + $this->assertResult( + '', + 'alert();' + ); + } + + function testRemoveOnlyScriptTags() { + $this->config->set('Core.HiddenElements', array()); + $this->assertResult( + '', + 'alert();' + ); + } + + function testRemoveInvalidImg() { + $this->assertResult('', ''); + } + + function testPreserveValidImg() { + $this->assertResult('foobar.gif'); + } + + function testPreserveInvalidImgWhenRemovalIsDisabled() { + $this->config->set('Core.RemoveInvalidImg', false); + $this->assertResult(''); + } + + function testTextifyCommentedScriptContents() { + $this->config->set('HTML.Trusted', true); + $this->config->set('Output.CommentScriptContents', false); // simplify output + $this->assertResult( +'', +'' + ); + } + + function testRequiredAttributesTestNotPerformedOnEndTag() { + $def = $this->config->getHTMLDefinition(true); + $def->addElement('f', 'Block', 'Optional: #PCDATA', false, array('req*' => 'Text')); + $this->assertResult('Foo Bar'); + } + + function testPreserveCommentsWithHTMLTrusted() { + $this->config->set('HTML.Trusted', true); + $this->assertResult(''); + } + + function testRemoveTrailingHyphensInComment() { + $this->config->set('HTML.Trusted', true); + $this->assertResult('', ''); + } + + function testCollapseDoubleHyphensInComment() { + $this->config->set('HTML.Trusted', true); + $this->assertResult('', ''); + } + + function testPreserveCommentsWithLookup() { + $this->config->set('HTML.AllowedComments', array('allowed')); + $this->assertResult('', ''); + } + + function testPreserveCommentsWithRegexp() { + $this->config->set('HTML.AllowedCommentsRegexp', '/^allowed[1-9]$/'); + $this->assertResult('', ''); + } + +} + +// vim: et sw=4 sts=4 -- cgit v1.2.3