Fix newline issues in tests.
[htmlpurifier/darkodev.git] / tests / HTMLPurifier / URISchemeTest.php
blob08c565d8625eddb7c355252ba14864f5a3df08a4
1 <?php
3 // WARNING: All the URI schemes are far to relaxed, we need to tighten
4 // the checks.
6 class HTMLPurifier_URISchemeTest extends HTMLPurifier_URIHarness
9 protected function assertValidation($uri, $expect_uri = true) {
10 $this->prepareURI($uri, $expect_uri);
11 // convenience hack: the scheme should be explicitly specified
12 $scheme = $uri->getSchemeObj($this->config, $this->context);
13 $result = $scheme->validate($uri, $this->config, $this->context);
14 $this->assertEitherFailOrIdentical($result, $uri, $expect_uri);
17 function test_http_regular() {
18 $this->assertValidation(
19 'http://example.com/?s=q#fragment'
23 function test_http_removeDefaultPort() {
24 $this->assertValidation(
25 'http://example.com:80',
26 'http://example.com'
30 function test_http_removeUserInfo() {
31 $this->assertValidation(
32 'http://bob@example.com',
33 'http://example.com'
37 function test_http_preserveNonDefaultPort() {
38 $this->assertValidation(
39 'http://example.com:8080'
43 function test_https_regular() {
44 $this->assertValidation(
45 'https://user@example.com:443/?s=q#frag',
46 'https://example.com/?s=q#frag'
50 function test_ftp_regular() {
51 $this->assertValidation(
52 'ftp://user@example.com/path'
56 function test_ftp_removeDefaultPort() {
57 $this->assertValidation(
58 'ftp://example.com:21',
59 'ftp://example.com'
63 function test_ftp_removeQueryString() {
64 $this->assertValidation(
65 'ftp://example.com?s=q',
66 'ftp://example.com'
70 function test_ftp_preserveValidTypecode() {
71 $this->assertValidation(
72 'ftp://example.com/file.txt;type=a'
76 function test_ftp_removeInvalidTypecode() {
77 $this->assertValidation(
78 'ftp://example.com/file.txt;type=z',
79 'ftp://example.com/file.txt'
83 function test_ftp_encodeExtraSemicolons() {
84 $this->assertValidation(
85 'ftp://example.com/too;many;semicolons=1',
86 'ftp://example.com/too%3Bmany%3Bsemicolons=1'
90 function test_news_regular() {
91 $this->assertValidation(
92 'news:gmane.science.linguistics'
96 function test_news_explicit() {
97 $this->assertValidation(
98 'news:642@eagle.ATT.COM'
102 function test_news_removeNonPathComponents() {
103 $this->assertValidation(
104 'news://user@example.com:80/rec.music?path=foo#frag',
105 'news:/rec.music#frag'
109 function test_nntp_regular() {
110 $this->assertValidation(
111 'nntp://news.example.com/alt.misc/42#frag'
115 function test_nntp_removalOfRedundantOrUselessComponents() {
116 $this->assertValidation(
117 'nntp://user@news.example.com:119/alt.misc/42?s=q#frag',
118 'nntp://news.example.com/alt.misc/42#frag'
122 function test_mailto_regular() {
123 $this->assertValidation(
124 'mailto:bob@example.com'
128 function test_mailto_removalOfRedundantOrUselessComponents() {
129 $this->assertValidation(
130 'mailto://user@example.com:80/bob@example.com?subject=Foo#frag',
131 'mailto:/bob@example.com?subject=Foo#frag'