Release 2.0.1, merged in 1181 to HEAD.
[htmlpurifier.git] / tests / HTMLPurifier / AttrDef / URI / IPv6Test.php
blob33b56ad403e1196d58e6678c3b080c85b5fde816
1 <?php
3 require_once 'HTMLPurifier/AttrDefHarness.php';
4 require_once 'HTMLPurifier/AttrDef/URI/IPv6.php';
6 // test case is from Feyd's IPv6 implementation
7 // we ought to disallow non-routable addresses
9 class HTMLPurifier_AttrDef_URI_IPv6Test extends HTMLPurifier_AttrDefHarness
12 function test() {
14 $this->def = new HTMLPurifier_AttrDef_URI_IPv6();
16 $this->assertDef('2001:DB8:0:0:8:800:200C:417A'); // unicast, full
17 $this->assertDef('FF01:0:0:0:0:0:0:101'); // multicast, full
18 $this->assertDef('0:0:0:0:0:0:0:1'); // loopback, full
19 $this->assertDef('0:0:0:0:0:0:0:0'); // unspecified, full
20 $this->assertDef('2001:DB8::8:800:200C:417A'); // unicast, compressed
21 $this->assertDef('FF01::101'); // multicast, compressed
23 $this->assertDef('::1'); // loopback, compressed, non-routable
24 $this->assertDef('::'); // unspecified, compressed, non-routable
25 $this->assertDef('0:0:0:0:0:0:13.1.68.3'); // IPv4-compatible IPv6 address, full, deprecated
26 $this->assertDef('0:0:0:0:0:FFFF:129.144.52.38'); // IPv4-mapped IPv6 address, full
27 $this->assertDef('::13.1.68.3'); // IPv4-compatible IPv6 address, compressed, deprecated
28 $this->assertDef('::FFFF:129.144.52.38'); // IPv4-mapped IPv6 address, compressed
29 $this->assertDef('2001:0DB8:0000:CD30:0000:0000:0000:0000/60'); // full, with prefix
30 $this->assertDef('2001:0DB8::CD30:0:0:0:0/60'); // compressed, with prefix
31 $this->assertDef('2001:0DB8:0:CD30::/60'); // compressed, with prefix #2
32 $this->assertDef('::/128'); // compressed, unspecified address type, non-routable
33 $this->assertDef('::1/128'); // compressed, loopback address type, non-routable
34 $this->assertDef('FF00::/8'); // compressed, multicast address type
35 $this->assertDef('FE80::/10'); // compressed, link-local unicast, non-routable
36 $this->assertDef('FEC0::/10'); // compressed, site-local unicast, deprecated
38 $this->assertDef('2001:DB8:0:0:8:800:200C:417A:221', false); // unicast, full
39 $this->assertDef('FF01::101::2', false); //multicast, compressed
40 $this->assertDef('', false); // nothing