mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-31 03:10:09 +02:00
[1.2.0] Add context parameter to URIScheme and URISchemeRegistry classes.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@500 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -18,24 +18,25 @@ class HTMLPurifier_URISchemeTest extends UnitTestCase
|
||||
function test_http() {
|
||||
$scheme = new HTMLPurifier_URIScheme_http();
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$context = new HTMLPurifier_Context();
|
||||
|
||||
$this->assertIdentical(
|
||||
$scheme->validateComponents(
|
||||
null, 'www.example.com', null, '/', 's=foobar', $config),
|
||||
null, 'www.example.com', null, '/', 's=foobar', $config, $context),
|
||||
array(null, 'www.example.com', null, '/', 's=foobar')
|
||||
);
|
||||
|
||||
// absorb default port and userinfo
|
||||
$this->assertIdentical(
|
||||
$scheme->validateComponents(
|
||||
'user', 'www.example.com', 80, '/', 's=foobar', $config),
|
||||
'user', 'www.example.com', 80, '/', 's=foobar', $config, $context),
|
||||
array(null, 'www.example.com', null, '/', 's=foobar')
|
||||
);
|
||||
|
||||
// do not absorb non-default port
|
||||
$this->assertIdentical(
|
||||
$scheme->validateComponents(
|
||||
null, 'www.example.com', 8080, '/', 's=foobar', $config),
|
||||
null, 'www.example.com', 8080, '/', 's=foobar', $config, $context),
|
||||
array(null, 'www.example.com', 8080, '/', 's=foobar')
|
||||
);
|
||||
|
||||
@@ -44,7 +45,7 @@ class HTMLPurifier_URISchemeTest extends UnitTestCase
|
||||
$scheme = new HTMLPurifier_URIScheme_https();
|
||||
$this->assertIdentical(
|
||||
$scheme->validateComponents(
|
||||
'user', 'www.example.com', 443, '/', 's=foobar', $config),
|
||||
'user', 'www.example.com', 443, '/', 's=foobar', $config, $context),
|
||||
array(null, 'www.example.com', null, '/', 's=foobar')
|
||||
);
|
||||
|
||||
@@ -54,31 +55,32 @@ class HTMLPurifier_URISchemeTest extends UnitTestCase
|
||||
|
||||
$scheme = new HTMLPurifier_URIScheme_ftp();
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$context = new HTMLPurifier_Context();
|
||||
|
||||
$this->assertIdentical(
|
||||
$scheme->validateComponents(
|
||||
'user', 'www.example.com', 21, '/', 's=foobar', $config),
|
||||
'user', 'www.example.com', 21, '/', 's=foobar', $config, $context),
|
||||
array('user', 'www.example.com', null, '/', null)
|
||||
);
|
||||
|
||||
// valid typecode
|
||||
$this->assertIdentical(
|
||||
$scheme->validateComponents(
|
||||
null, 'www.example.com', null, '/file.txt;type=a', null, $config),
|
||||
null, 'www.example.com', null, '/file.txt;type=a', null, $config, $context),
|
||||
array(null, 'www.example.com', null, '/file.txt;type=a', null)
|
||||
);
|
||||
|
||||
// remove invalid typecode
|
||||
$this->assertIdentical(
|
||||
$scheme->validateComponents(
|
||||
null, 'www.example.com', null, '/file.txt;type=z', null, $config),
|
||||
null, 'www.example.com', null, '/file.txt;type=z', null, $config, $context),
|
||||
array(null, 'www.example.com', null, '/file.txt', null)
|
||||
);
|
||||
|
||||
// encode errant semicolons
|
||||
$this->assertIdentical(
|
||||
$scheme->validateComponents(
|
||||
null, 'www.example.com', null, '/too;many;semicolons=1', null, $config),
|
||||
null, 'www.example.com', null, '/too;many;semicolons=1', null, $config, $context),
|
||||
array(null, 'www.example.com', null, '/too%3Bmany%3Bsemicolons=1', null)
|
||||
);
|
||||
|
||||
@@ -88,23 +90,24 @@ class HTMLPurifier_URISchemeTest extends UnitTestCase
|
||||
|
||||
$scheme = new HTMLPurifier_URIScheme_news();
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$context = new HTMLPurifier_Context();
|
||||
|
||||
$this->assertIdentical(
|
||||
$scheme->validateComponents(
|
||||
null, null, null, 'gmane.science.linguistics', null, $config),
|
||||
null, null, null, 'gmane.science.linguistics', null, $config, $context),
|
||||
array(null, null, null, 'gmane.science.linguistics', null)
|
||||
);
|
||||
|
||||
$this->assertIdentical(
|
||||
$scheme->validateComponents(
|
||||
null, null, null, '642@eagle.ATT.COM', null, $config),
|
||||
null, null, null, '642@eagle.ATT.COM', null, $config, $context),
|
||||
array(null, null, null, '642@eagle.ATT.COM', null)
|
||||
);
|
||||
|
||||
// test invalid field removal
|
||||
$this->assertIdentical(
|
||||
$scheme->validateComponents(
|
||||
'user', 'www.google.com', 80, 'rec.music', 'path=foo', $config),
|
||||
'user', 'www.google.com', 80, 'rec.music', 'path=foo', $config, $context),
|
||||
array(null, null, null, 'rec.music', null)
|
||||
);
|
||||
|
||||
@@ -114,17 +117,18 @@ class HTMLPurifier_URISchemeTest extends UnitTestCase
|
||||
|
||||
$scheme = new HTMLPurifier_URIScheme_nntp();
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$context = new HTMLPurifier_Context();
|
||||
|
||||
$this->assertIdentical(
|
||||
$scheme->validateComponents(
|
||||
null, 'news.example.com', null, '/alt.misc/12345', null, $config),
|
||||
null, 'news.example.com', null, '/alt.misc/12345', null, $config, $context),
|
||||
array(null, 'news.example.com', null, '/alt.misc/12345', null)
|
||||
);
|
||||
|
||||
|
||||
$this->assertIdentical(
|
||||
$scheme->validateComponents(
|
||||
'user', 'news.example.com', 119, '/alt.misc/12345', 'foo=asdf', $config),
|
||||
'user', 'news.example.com', 119, '/alt.misc/12345', 'foo=asdf', $config, $context),
|
||||
array(null, 'news.example.com', null, '/alt.misc/12345', null)
|
||||
);
|
||||
}
|
||||
@@ -133,16 +137,17 @@ class HTMLPurifier_URISchemeTest extends UnitTestCase
|
||||
|
||||
$scheme = new HTMLPurifier_URIScheme_mailto();
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$context = new HTMLPurifier_Context();
|
||||
|
||||
$this->assertIdentical(
|
||||
$scheme->validateComponents(
|
||||
null, null, null, 'bob@example.com', null, $config),
|
||||
null, null, null, 'bob@example.com', null, $config, $context),
|
||||
array(null, null, null, 'bob@example.com', null)
|
||||
);
|
||||
|
||||
$this->assertIdentical(
|
||||
$scheme->validateComponents(
|
||||
'user', 'example.com', 80, 'bob@example.com', 'subject=Foo!', $config),
|
||||
'user', 'example.com', 80, 'bob@example.com', 'subject=Foo!', $config, $context),
|
||||
array(null, null, null, 'bob@example.com', 'subject=Foo!')
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user