3 class HTMLPurifier_URIParserTest
extends HTMLPurifier_Harness
6 protected function assertParsing(
7 $uri, $scheme, $userinfo, $host, $port, $path, $query, $fragment, $config = null, $context = null
9 $this->prepareCommon($config, $context);
10 $parser = new HTMLPurifier_URIParser();
11 $result = $parser->parse($uri, $config, $context);
12 $expect = new HTMLPurifier_URI($scheme, $userinfo, $host, $port, $path, $query, $fragment);
13 $this->assertEqual($result, $expect);
16 function testPercentNormalization() {
19 null, null, null, null, '%25G', null, null
23 function testRegular() {
25 'http://www.example.com/webhp?q=foo#result2',
26 'http', null, 'www.example.com', null, '/webhp', 'q=foo', 'result2'
30 function testPortAndUsername() {
32 'http://user@authority.part:80/now/the/path?query#fragment',
33 'http', 'user', 'authority.part', 80, '/now/the/path', 'query', 'fragment'
37 function testPercentEncoding() {
39 'http://en.wikipedia.org/wiki/Clich%C3%A9',
40 'http', null, 'en.wikipedia.org', null, '/wiki/Clich%C3%A9', null, null
44 function testEmptyQuery() {
46 'http://www.example.com/?#',
47 'http', null, 'www.example.com', null, '/', '', null
51 function testEmptyPath() {
53 'http://www.example.com',
54 'http', null, 'www.example.com', null, '', null, null
58 function testOpaqueURI() {
60 'mailto:bob@example.com',
61 'mailto', null, null, null, 'bob@example.com', null, null
65 function testIPv4Address() {
67 'http://192.0.34.166/',
68 'http', null, '192.0.34.166', null, '/', null, null
72 function testFakeIPv4Address() {
74 'http://333.123.32.123/',
75 'http', null, '333.123.32.123', null, '/', null, null
79 function testIPv6Address() {
81 'http://[2001:db8::7]/c=GB?objectClass?one',
82 'http', null, '[2001:db8::7]', null, '/c=GB', 'objectClass?one', null
86 function testInternationalizedDomainName() {
88 "http://t\xC5\xABdali\xC5\x86.lv",
89 'http', null, "t\xC5\xABdali\xC5\x86.lv", null, '', null, null
93 function testInvalidPort() {
95 'http://example.com:foobar',
96 'http', null, 'example.com', null, '', null, null
100 function testPathAbsolute() {
101 $this->assertParsing(
102 'http:/this/is/path',
103 'http', null, null, null, '/this/is/path', null, null
107 function testPathRootless() {
108 // this should not be used but is allowed
109 $this->assertParsing(
111 'http', null, null, null, 'this/is/path', null, null
115 function testPathEmpty() {
116 $this->assertParsing(
118 'http', null, null, null, '', null, null
122 function testRelativeURI() {
123 $this->assertParsing(
125 null, null, null, null, '/a/b', null, null
129 function testMalformedTag() {
130 $this->assertParsing(
131 'http://www.example.com/>',
132 'http', null, 'www.example.com', null, '/', null, null
136 function testEmpty() {
137 $this->assertParsing(
139 null, null, null, null, '', null, null