diff options
Diffstat (limited to 'lib/htmlpurifier/tests/HTMLPurifier/URIFilter')
6 files changed, 0 insertions, 420 deletions
diff --git a/lib/htmlpurifier/tests/HTMLPurifier/URIFilter/DisableExternalResourcesTest.php b/lib/htmlpurifier/tests/HTMLPurifier/URIFilter/DisableExternalResourcesTest.php deleted file mode 100644 index 21c70c145..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/URIFilter/DisableExternalResourcesTest.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php - -class HTMLPurifier_URIFilter_DisableExternalResourcesTest extends - HTMLPurifier_URIFilter_DisableExternalTest -{ - - function setUp() { - parent::setUp(); - $this->filter = new HTMLPurifier_URIFilter_DisableExternalResources(); - $var = true; - $this->context->register('EmbeddedURI', $var); - } - - function testPreserveWhenNotEmbedded() { - $this->context->destroy('EmbeddedURI'); // undo setUp - $this->assertFiltering( - 'http://example.com' - ); - } - -} - -// vim: et sw=4 sts=4 diff --git a/lib/htmlpurifier/tests/HTMLPurifier/URIFilter/DisableExternalTest.php b/lib/htmlpurifier/tests/HTMLPurifier/URIFilter/DisableExternalTest.php deleted file mode 100644 index 3176246a1..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/URIFilter/DisableExternalTest.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -class HTMLPurifier_URIFilter_DisableExternalTest extends HTMLPurifier_URIFilterHarness -{ - - function setUp() { - parent::setUp(); - $this->filter = new HTMLPurifier_URIFilter_DisableExternal(); - } - - function testRemoveExternal() { - $this->assertFiltering( - 'http://example.com', false - ); - } - - function testPreserveInternal() { - $this->assertFiltering( - '/foo/bar' - ); - } - - function testPreserveOurHost() { - $this->config->set('URI.Host', 'example.com'); - $this->assertFiltering( - 'http://example.com' - ); - } - - function testPreserveOurSubdomain() { - $this->config->set('URI.Host', 'example.com'); - $this->assertFiltering( - 'http://www.example.com' - ); - } - - function testRemoveSuperdomain() { - $this->config->set('URI.Host', 'www.example.com'); - $this->assertFiltering( - 'http://example.com', false - ); - } - - function testBaseAsHost() { - $this->config->set('URI.Base', 'http://www.example.com/foo/bar'); - $this->assertFiltering( - 'http://www.example.com/baz' - ); - } - -} - -// vim: et sw=4 sts=4 diff --git a/lib/htmlpurifier/tests/HTMLPurifier/URIFilter/DisableResourcesTest.php b/lib/htmlpurifier/tests/HTMLPurifier/URIFilter/DisableResourcesTest.php deleted file mode 100644 index c2cea8fe6..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/URIFilter/DisableResourcesTest.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php - -class HTMLPurifier_URIFilter_DisableResourcesTest extends HTMLPurifier_URIFilterHarness -{ - - function setUp() { - parent::setUp(); - $this->filter = new HTMLPurifier_URIFilter_DisableResources(); - $var = true; - $this->context->register('EmbeddedURI', $var); - } - - function testRemoveResource() { - $this->assertFiltering('/foo/bar', false); - } - - function testPreserveRegular() { - $this->context->destroy('EmbeddedURI'); // undo setUp - $this->assertFiltering('/foo/bar'); - } - -} - -// vim: et sw=4 sts=4 diff --git a/lib/htmlpurifier/tests/HTMLPurifier/URIFilter/HostBlacklistTest.php b/lib/htmlpurifier/tests/HTMLPurifier/URIFilter/HostBlacklistTest.php deleted file mode 100644 index 4af5a6009..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/URIFilter/HostBlacklistTest.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -class HTMLPurifier_URIFilter_HostBlacklistTest extends HTMLPurifier_URIFilterHarness -{ - - function setUp() { - parent::setUp(); - $this->filter = new HTMLPurifier_URIFilter_HostBlacklist(); - } - - function testRejectBlacklistedHost() { - $this->config->set('URI.HostBlacklist', 'example.com'); - $this->assertFiltering('http://example.com', false); - } - - function testRejectBlacklistedHostThoughNotTrue() { - // maybe this behavior should change - $this->config->set('URI.HostBlacklist', 'example.com'); - $this->assertFiltering('http://example.comcast.com', false); - } - - function testPreserveNonBlacklistedHost() { - $this->config->set('URI.HostBlacklist', 'example.com'); - $this->assertFiltering('http://google.com'); - } - -} - -// vim: et sw=4 sts=4 diff --git a/lib/htmlpurifier/tests/HTMLPurifier/URIFilter/MakeAbsoluteTest.php b/lib/htmlpurifier/tests/HTMLPurifier/URIFilter/MakeAbsoluteTest.php deleted file mode 100644 index 9002f1ff8..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/URIFilter/MakeAbsoluteTest.php +++ /dev/null @@ -1,146 +0,0 @@ -<?php - -class HTMLPurifier_URIFilter_MakeAbsoluteTest extends HTMLPurifier_URIFilterHarness -{ - - function setUp() { - parent::setUp(); - $this->filter = new HTMLPurifier_URIFilter_MakeAbsolute(); - $this->setBase(); - } - - function setBase($base = 'http://example.com/foo/bar.html?q=s#frag') { - $this->config->set('URI.Base', $base); - } - - // corresponding to RFC 2396 - - function testPreserveAbsolute() { - $this->assertFiltering('http://example.com/foo.html'); - } - - function testFilterBlank() { - $this->assertFiltering('', 'http://example.com/foo/bar.html?q=s'); - } - - function testFilterEmptyPath() { - $this->assertFiltering('?q=s#frag', 'http://example.com/foo/bar.html?q=s#frag'); - } - - function testPreserveAltScheme() { - $this->assertFiltering('mailto:bob@example.com'); - } - - function testFilterIgnoreHTTPSpecialCase() { - $this->assertFiltering('http:/', 'http://example.com/'); - } - - function testFilterAbsolutePath() { - $this->assertFiltering('/foo.txt', 'http://example.com/foo.txt'); - } - - function testFilterRelativePath() { - $this->assertFiltering('baz.txt', 'http://example.com/foo/baz.txt'); - } - - function testFilterRelativePathWithInternalDot() { - $this->assertFiltering('./baz.txt', 'http://example.com/foo/baz.txt'); - } - - function testFilterRelativePathWithEndingDot() { - $this->assertFiltering('baz/.', 'http://example.com/foo/baz/'); - } - - function testFilterRelativePathDot() { - $this->assertFiltering('.', 'http://example.com/foo/'); - } - - function testFilterRelativePathMultiDot() { - $this->assertFiltering('././foo/./bar/.././baz', 'http://example.com/foo/foo/baz'); - } - - function testFilterAbsolutePathWithDot() { - $this->assertFiltering('/./foo', 'http://example.com/foo'); - } - - function testFilterAbsolutePathWithMultiDot() { - $this->assertFiltering('/./foo/../bar/.', 'http://example.com/bar/'); - } - - function testFilterRelativePathWithInternalDotDot() { - $this->assertFiltering('../baz.txt', 'http://example.com/baz.txt'); - } - - function testFilterRelativePathWithEndingDotDot() { - $this->assertFiltering('..', 'http://example.com/'); - } - - function testFilterRelativePathTooManyDotDots() { - $this->assertFiltering('../../', 'http://example.com/'); - } - - function testFilterAppendingQueryAndFragment() { - $this->assertFiltering('/foo.php?q=s#frag', 'http://example.com/foo.php?q=s#frag'); - } - - // edge cases below - - function testFilterAbsolutePathBase() { - $this->setBase('/foo/baz.txt'); - $this->assertFiltering('test.php', '/foo/test.php'); - } - - function testFilterAbsolutePathBaseDirectory() { - $this->setBase('/foo/'); - $this->assertFiltering('test.php', '/foo/test.php'); - } - - function testFilterAbsolutePathBaseBelow() { - $this->setBase('/foo/baz.txt'); - $this->assertFiltering('../../test.php', '/test.php'); - } - - function testFilterRelativePathBase() { - $this->setBase('foo/baz.html'); - $this->assertFiltering('foo.php', 'foo/foo.php'); - } - - function testFilterRelativePathBaseBelow() { - $this->setBase('../baz.html'); - $this->assertFiltering('test/strike.html', '../test/strike.html'); - } - - function testFilterRelativePathBaseWithAbsoluteURI() { - $this->setBase('../baz.html'); - $this->assertFiltering('/test/strike.html'); - } - - function testFilterRelativePathBaseWithDot() { - $this->setBase('../baz.html'); - $this->assertFiltering('.', '../'); - } - - function testRemoveJavaScriptWithEmbeddedLink() { - // credits: NykO18 - $this->setBase('http://www.example.com/'); - $this->assertFiltering('javascript: window.location = \'http://www.example.com\';', false); - } - - // miscellaneous - - function testFilterDomainWithNoSlash() { - $this->setBase('http://example.com'); - $this->assertFiltering('foo', 'http://example.com/foo'); - } - - // error case - - function testErrorNoBase() { - $this->setBase(null); - $this->expectError('URI.MakeAbsolute is being ignored due to lack of value for URI.Base configuration'); - $this->assertFiltering('foo/bar.txt'); - } - -} - -// vim: et sw=4 sts=4 diff --git a/lib/htmlpurifier/tests/HTMLPurifier/URIFilter/MungeTest.php b/lib/htmlpurifier/tests/HTMLPurifier/URIFilter/MungeTest.php deleted file mode 100644 index 1acf11ea7..000000000 --- a/lib/htmlpurifier/tests/HTMLPurifier/URIFilter/MungeTest.php +++ /dev/null @@ -1,145 +0,0 @@ -<?php - -class HTMLPurifier_URIFilter_MungeTest extends HTMLPurifier_URIFilterHarness -{ - - function setUp() { - parent::setUp(); - $this->filter = new HTMLPurifier_URIFilter_Munge(); - } - - protected function setMunge($uri = 'http://www.google.com/url?q=%s') { - $this->config->set('URI.Munge', $uri); - } - - protected function setSecureMunge($key = 'secret') { - $this->setMunge('/redirect.php?url=%s&checksum=%t'); - $this->config->set('URI.MungeSecretKey', $key); - } - - function testMunge() { - $this->setMunge(); - $this->assertFiltering( - 'http://www.example.com/', - 'http://www.google.com/url?q=http%3A%2F%2Fwww.example.com%2F' - ); - } - - function testMungeReplaceTagName() { - $this->setMunge('/r?tagname=%n&url=%s'); - $token = new HTMLPurifier_Token_Start('a'); - $this->context->register('CurrentToken', $token); - $this->assertFiltering('http://google.com', '/r?tagname=a&url=http%3A%2F%2Fgoogle.com'); - } - - function testMungeReplaceAttribute() { - $this->setMunge('/r?attr=%m&url=%s'); - $attr = 'href'; - $this->context->register('CurrentAttr', $attr); - $this->assertFiltering('http://google.com', '/r?attr=href&url=http%3A%2F%2Fgoogle.com'); - } - - function testMungeReplaceResource() { - $this->setMunge('/r?embeds=%r&url=%s'); - $embeds = false; - $this->context->register('EmbeddedURI', $embeds); - $this->assertFiltering('http://google.com', '/r?embeds=&url=http%3A%2F%2Fgoogle.com'); - } - - function testMungeReplaceCSSProperty() { - $this->setMunge('/r?property=%p&url=%s'); - $property = 'background'; - $this->context->register('CurrentCSSProperty', $property); - $this->assertFiltering('http://google.com', '/r?property=background&url=http%3A%2F%2Fgoogle.com'); - } - - function testIgnoreEmbedded() { - $this->setMunge(); - $embeds = true; - $this->context->register('EmbeddedURI', $embeds); - $this->assertFiltering('http://example.com'); - } - - function testProcessEmbedded() { - $this->setMunge(); - $this->config->set('URI.MungeResources', true); - $embeds = true; - $this->context->register('EmbeddedURI', $embeds); - $this->assertFiltering('http://www.example.com/', 'http://www.google.com/url?q=http%3A%2F%2Fwww.example.com%2F'); - } - - function testPreserveRelative() { - $this->setMunge(); - $this->assertFiltering('index.html'); - } - - function testMungeIgnoreUnknownSchemes() { - $this->setMunge(); - $this->assertFiltering('javascript:foobar();', true); - } - - function testSecureMungePreserve() { - $this->setSecureMunge(); - $this->assertFiltering('/local'); - } - - function testSecureMungePreserveEmbedded() { - $this->setSecureMunge(); - $embedded = true; - $this->context->register('EmbeddedURI', $embedded); - $this->assertFiltering('http://google.com'); - } - - function testSecureMungeStandard() { - $this->setSecureMunge(); - $this->assertFiltering('http://google.com', '/redirect.php?url=http%3A%2F%2Fgoogle.com&checksum=0072e2f817fd2844825def74e54443debecf0892'); - } - - function testSecureMungeIgnoreUnknownSchemes() { - // This should be integration tested as well to be false - $this->setSecureMunge(); - $this->assertFiltering('javascript:', true); - } - - function testSecureMungeIgnoreUnbrowsableSchemes() { - $this->setSecureMunge(); - $this->assertFiltering('news:', true); - } - - function testSecureMungeToDirectory() { - $this->setSecureMunge(); - $this->setMunge('/links/%s/%t'); - $this->assertFiltering('http://google.com', '/links/http%3A%2F%2Fgoogle.com/0072e2f817fd2844825def74e54443debecf0892'); - } - - function testMungeIgnoreSameDomain() { - $this->setMunge('http://example.com/%s'); - $this->assertFiltering('http://example.com/foobar'); - } - - function testMungeIgnoreSameDomainInsecureToSecure() { - $this->setMunge('http://example.com/%s'); - $this->assertFiltering('https://example.com/foobar'); - } - - function testMungeIgnoreSameDomainSecureToSecure() { - $this->config->set('URI.Base', 'https://example.com'); - $this->setMunge('http://example.com/%s'); - $this->assertFiltering('https://example.com/foobar'); - } - - function testMungeSameDomainSecureToInsecure() { - $this->config->set('URI.Base', 'https://example.com'); - $this->setMunge('/%s'); - $this->assertFiltering('http://example.com/foobar', '/http%3A%2F%2Fexample.com%2Ffoobar'); - } - - function testMungeIgnoresSourceHost() { - $this->config->set('URI.Host', 'foo.example.com'); - $this->setMunge('http://example.com/%s'); - $this->assertFiltering('http://foo.example.com/bar'); - } - -} - -// vim: et sw=4 sts=4 |