File indexing completed on 2024-05-12 06:02:06
0001 <?php 0002 0003 // It's not clear to me whether or not Punycode means that hostnames 0004 // do not have canonical forms anymore. As far as I can tell, it's 0005 // not a problem (punycoding should be identity when no Unicode 0006 // points are involved), but I'm not 100% sure 0007 class HTMLPurifier_URIFilter_HostBlacklist extends HTMLPurifier_URIFilter 0008 { 0009 /** 0010 * @type string 0011 */ 0012 public $name = 'HostBlacklist'; 0013 0014 /** 0015 * @type array 0016 */ 0017 protected $blacklist = array(); 0018 0019 /** 0020 * @param HTMLPurifier_Config $config 0021 * @return bool 0022 */ 0023 public function prepare($config) 0024 { 0025 $this->blacklist = $config->get('URI.HostBlacklist'); 0026 return true; 0027 } 0028 0029 /** 0030 * @param HTMLPurifier_URI $uri 0031 * @param HTMLPurifier_Config $config 0032 * @param HTMLPurifier_Context $context 0033 * @return bool 0034 */ 0035 public function filter(&$uri, $config, $context) 0036 { 0037 foreach ($this->blacklist as $blacklisted_host_fragment) { 0038 if (strpos($uri->host, $blacklisted_host_fragment) !== false) { 0039 return false; 0040 } 0041 } 0042 return true; 0043 } 0044 } 0045 0046 // vim: et sw=4 sts=4