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/ValidateAttributesTest.php | 232 +++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 lib/htmlpurifier/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php (limited to 'lib/htmlpurifier/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php') diff --git a/lib/htmlpurifier/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php b/lib/htmlpurifier/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php new file mode 100644 index 000000000..5fc86cbda --- /dev/null +++ b/lib/htmlpurifier/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php @@ -0,0 +1,232 @@ +obj = new HTMLPurifier_Strategy_ValidateAttributes(); + } + + function testEmptyInput() { + $this->assertResult(''); + } + + function testRemoveIDByDefault() { + $this->assertResult( + '
Kill the ID.
', + '
Kill the ID.
' + ); + } + + function testRemoveInvalidDir() { + $this->assertResult( + 'Bad dir.', + 'Bad dir.' + ); + } + + function testPreserveValidClass() { + $this->assertResult('
Valid
'); + } + + function testSelectivelyRemoveInvalidClasses() { + $this->config->set('HTML.Doctype', 'XHTML 1.1'); + $this->assertResult( + '
Keep valid.
', + '
Keep valid.
' + ); + } + + function testPreserveTitle() { + $this->assertResult( + 'PHP' + ); + } + + function testAddXMLLang() { + $this->assertResult( + 'La soupe.', + 'La soupe.' + ); + } + + function testOnlyXMLLangInXHTML11() { + $this->config->set('HTML.Doctype', 'XHTML 1.1'); + $this->assertResult( + 'asdf', + 'asdf' + ); + } + + function testBasicURI() { + $this->assertResult('Google'); + } + + function testInvalidURI() { + $this->assertResult( + 'Google', + 'Google' + ); + } + + function testBdoAddMissingDir() { + $this->assertResult( + 'Go left.', + 'Go left.' + ); + } + + function testBdoReplaceInvalidDirWithDefault() { + $this->assertResult( + 'Invalid value!', + 'Invalid value!' + ); + } + + function testBdoAlternateDefaultDir() { + $this->config->set('Attr.DefaultTextDir', 'rtl'); + $this->assertResult( + 'Go right.', + 'Go right.' + ); + } + + function testRemoveDirWhenNotRequired() { + $this->assertResult( + 'Invalid value!', + 'Invalid value!' + ); + } + + function testTableAttributes() { + $this->assertResult( +' + + + + + + + + + + + + + +
Fiddly nameSuper-duper-price
Carrot Humungous$500.23
Taken off the market
' + ); + } + + function testColSpanIsNonZero() { + $this->assertResult( + '', + '' + ); + } + + function testImgAddDefaults() { + $this->config->set('Core.RemoveInvalidImg', false); + $this->assertResult( + '', + 'Invalid image' + ); + } + + function testImgGenerateAlt() { + $this->assertResult( + '', + 'foobar.jpg' + ); + } + + function testImgAddDefaultSrc() { + $this->config->set('Core.RemoveInvalidImg', false); + $this->assertResult( + 'pretty picture', + 'pretty picture' + ); + } + + function testImgRemoveNonRetrievableProtocol() { + $this->config->set('Core.RemoveInvalidImg', false); + $this->assertResult( + '', + 'mailto:foo@example.com' + ); + } + + function testPreserveRel() { + $this->config->set('Attr.AllowedRel', 'nofollow'); + $this->assertResult(''); + } + + function testPreserveTarget() { + $this->config->set('Attr.AllowedFrameTargets', '_top'); + $this->config->set('HTML.Doctype', 'XHTML 1.0 Transitional'); + $this->assertResult(''); + } + + function testRemoveTargetWhenNotSupported() { + $this->config->set('HTML.Doctype', 'XHTML 1.0 Strict'); + $this->config->set('Attr.AllowedFrameTargets', '_top'); + $this->assertResult( + '', + '' + ); + } + + function testKeepAbsoluteCSSWidthAndHeightOnImg() { + $this->assertResult( + '' + ); + } + + function testRemoveLargeCSSWidthAndHeightOnImg() { + $this->assertResult( + '', + '' + ); + } + + function testRemoveLargeCSSWidthAndHeightOnImgWithUserConf() { + $this->config->set('CSS.MaxImgLength', '1px'); + $this->assertResult( + '', + '' + ); + } + + function testKeepLargeCSSWidthAndHeightOnImgWhenToldTo() { + $this->config->set('CSS.MaxImgLength', null); + $this->assertResult( + '' + ); + } + + function testKeepPercentCSSWidthAndHeightOnImgWhenToldTo() { + $this->config->set('CSS.MaxImgLength', null); + $this->assertResult( + '' + ); + } + + function testRemoveRelativeCSSWidthAndHeightOnImg() { + $this->assertResult( + '', + '' + ); + } + + function testRemovePercentCSSWidthAndHeightOnImg() { + $this->assertResult( + '', + '' + ); + } + +} + +// vim: et sw=4 sts=4 -- cgit v1.2.3