Whoops, forgot to edit WHATSNEW
[htmlpurifier.git] / library / HTMLPurifier / URIFilter / DisableExternal.php
blobced1b137636c0703d8022fda5993793dc2f052a5
1 <?php
3 class HTMLPurifier_URIFilter_DisableExternal extends HTMLPurifier_URIFilter
5 /**
6 * @type string
7 */
8 public $name = 'DisableExternal';
10 /**
11 * @type array
13 protected $ourHostParts = false;
15 /**
16 * @param HTMLPurifier_Config $config
17 * @return void
19 public function prepare($config)
21 $our_host = $config->getDefinition('URI')->host;
22 if ($our_host !== null) {
23 $this->ourHostParts = array_reverse(explode('.', $our_host));
27 /**
28 * @param HTMLPurifier_URI $uri Reference
29 * @param HTMLPurifier_Config $config
30 * @param HTMLPurifier_Context $context
31 * @return bool
33 public function filter(&$uri, $config, $context)
35 if (is_null($uri->host)) {
36 return true;
38 if ($this->ourHostParts === false) {
39 return false;
41 $host_parts = array_reverse(explode('.', $uri->host));
42 foreach ($this->ourHostParts as $i => $x) {
43 if (!isset($host_parts[$i])) {
44 return false;
46 if ($host_parts[$i] != $this->ourHostParts[$i]) {
47 return false;
50 return true;
54 // vim: et sw=4 sts=4