PSR-2 reformatting PHPDoc corrections
[htmlpurifier.git] / tests / HTMLPurifier / AttrDef / URI / HostTest.php
blob00e56ed4c43bf29e9f1ef136e8cb68d781162f07
1 <?php
3 // takes a URI formatted host and validates it
6 class HTMLPurifier_AttrDef_URI_HostTest extends HTMLPurifier_AttrDefHarness
9 public function test()
11 $this->def = new HTMLPurifier_AttrDef_URI_Host();
13 $this->assertDef('[2001:DB8:0:0:8:800:200C:417A]'); // IPv6
14 $this->assertDef('124.15.6.89'); // IPv4
15 $this->assertDef('www.google.com'); // reg-name
17 // more domain name tests
18 $this->assertDef('test.');
19 $this->assertDef('sub.test.');
20 $this->assertDef('.test', false);
21 $this->assertDef('ff');
22 $this->assertDef('1f', false);
23 $this->assertDef('-f', false);
24 $this->assertDef('f1');
25 $this->assertDef('f-', false);
26 $this->assertDef('sub.ff');
27 $this->assertDef('sub.1f', false);
28 $this->assertDef('sub.-f', false);
29 $this->assertDef('sub.f1');
30 $this->assertDef('sub.f-', false);
31 $this->assertDef('ff.top');
32 $this->assertDef('1f.top');
33 $this->assertDef('-f.top', false);
34 $this->assertDef('ff.top');
35 $this->assertDef('f1.top');
36 $this->assertDef('f1_f2.ex.top', false);
37 $this->assertDef('f-.top', false);
39 $this->assertDef("\xE4\xB8\xAD\xE6\x96\x87.com.cn", false);
43 public function testIDNA()
45 if (!$GLOBALS['HTMLPurifierTest']['Net_IDNA2']) {
46 return false;
48 $this->config->set('Core.EnableIDNA', true);
49 $this->assertDef("\xE4\xB8\xAD\xE6\x96\x87.com.cn", "xn--fiq228c.com.cn");
50 $this->assertDef("\xe2\x80\x85.com", false); // rejected
53 function testAllowUnderscore() {
54 $this->config->set('Core.AllowHostnameUnderscore', true);
55 $this->assertDef("foo_bar.example.com");
56 $this->assertDef("foo_.example.com", false);
61 // vim: et sw=4 sts=4