Docblock update
[htmlpurifier.git] / tests / HTMLPurifier / URIParserTest.php
bloba188862c9abc4f2856aa6e0e537c18cec2246dd9
1 <?php
3 class HTMLPurifier_URIParserTest extends HTMLPurifier_Harness
6 protected function assertParsing(
7 $uri, $scheme, $userinfo, $host, $port, $path, $query, $fragment, $config = null, $context = null
8 ) {
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 public function testPercentNormalization()
18 $this->assertParsing(
19 '%G',
20 null, null, null, null, '%25G', null, null
24 public function testRegular()
26 $this->assertParsing(
27 'http://www.example.com/webhp?q=foo#result2',
28 'http', null, 'www.example.com', null, '/webhp', 'q=foo', 'result2'
32 public function testPortAndUsername()
34 $this->assertParsing(
35 'http://user@authority.part:80/now/the/path?query#fragment',
36 'http', 'user', 'authority.part', 80, '/now/the/path', 'query', 'fragment'
40 public function testPercentEncoding()
42 $this->assertParsing(
43 'http://en.wikipedia.org/wiki/Clich%C3%A9',
44 'http', null, 'en.wikipedia.org', null, '/wiki/Clich%C3%A9', null, null
48 public function testEmptyQuery()
50 $this->assertParsing(
51 'http://www.example.com/?#',
52 'http', null, 'www.example.com', null, '/', '', null
56 public function testEmptyPath()
58 $this->assertParsing(
59 'http://www.example.com',
60 'http', null, 'www.example.com', null, '', null, null
64 public function testOpaqueURI()
66 $this->assertParsing(
67 'mailto:bob@example.com',
68 'mailto', null, null, null, 'bob@example.com', null, null
72 public function testIPv4Address()
74 $this->assertParsing(
75 'http://192.0.34.166/',
76 'http', null, '192.0.34.166', null, '/', null, null
80 public function testFakeIPv4Address()
82 $this->assertParsing(
83 'http://333.123.32.123/',
84 'http', null, '333.123.32.123', null, '/', null, null
88 public function testIPv6Address()
90 $this->assertParsing(
91 'http://[2001:db8::7]/c=GB?objectClass?one',
92 'http', null, '[2001:db8::7]', null, '/c=GB', 'objectClass?one', null
96 public function testInternationalizedDomainName()
98 $this->assertParsing(
99 "http://t\xC5\xABdali\xC5\x86.lv",
100 'http', null, "t\xC5\xABdali\xC5\x86.lv", null, '', null, null
104 public function testInvalidPort()
106 $this->assertParsing(
107 'http://example.com:foobar',
108 'http', null, 'example.com', null, '', null, null
112 public function testPathAbsolute()
114 $this->assertParsing(
115 'http:/this/is/path',
116 'http', null, null, null, '/this/is/path', null, null
120 public function testPathRootless()
122 // this should not be used but is allowed
123 $this->assertParsing(
124 'http:this/is/path',
125 'http', null, null, null, 'this/is/path', null, null
129 public function testPathEmpty()
131 $this->assertParsing(
132 'http:',
133 'http', null, null, null, '', null, null
137 public function testRelativeURI()
139 $this->assertParsing(
140 '/a/b',
141 null, null, null, null, '/a/b', null, null
145 public function testMalformedTag()
147 $this->assertParsing(
148 'http://www.example.com/>',
149 'http', null, 'www.example.com', null, '/', null, null
153 public function testEmpty()
155 $this->assertParsing(
157 null, null, null, null, '', null, null
161 public function testEmbeddedColon()
163 $this->assertParsing(
164 '{:test:}',
165 null, null, null, null, '{:test:}', null, null
171 // vim: et sw=4 sts=4