HTMLPurifier 4.4.0
/home/ezyang/Dev/htmlpurifier/library/HTMLPurifier/URIFilter/DisableExternal.php
Go to the documentation of this file.
00001 <?php
00002 
00003 class HTMLPurifier_URIFilter_DisableExternal extends HTMLPurifier_URIFilter
00004 {
00005     public $name = 'DisableExternal';
00006     protected $ourHostParts = false;
00007     public function prepare($config) {
00008         $our_host = $config->getDefinition('URI')->host;
00009         if ($our_host !== null) $this->ourHostParts = array_reverse(explode('.', $our_host));
00010     }
00011     public function filter(&$uri, $config, $context) {
00012         if (is_null($uri->host)) return true;
00013         if ($this->ourHostParts === false) return false;
00014         $host_parts = array_reverse(explode('.', $uri->host));
00015         foreach ($this->ourHostParts as $i => $x) {
00016             if (!isset($host_parts[$i])) return false;
00017             if ($host_parts[$i] != $this->ourHostParts[$i]) return false;
00018         }
00019         return true;
00020     }
00021 }
00022 
00023 // vim: et sw=4 sts=4