HTMLPurifier 4.4.0
|
00001 <?php 00002 00007 class HTMLPurifier_AttrDef_URI_IPv4 extends HTMLPurifier_AttrDef 00008 { 00009 00013 protected $ip4; 00014 00015 public function validate($aIP, $config, $context) { 00016 00017 if (!$this->ip4) $this->_loadRegex(); 00018 00019 if (preg_match('#^' . $this->ip4 . '$#s', $aIP)) 00020 { 00021 return $aIP; 00022 } 00023 00024 return false; 00025 00026 } 00027 00032 protected function _loadRegex() { 00033 $oct = '(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])'; // 0-255 00034 $this->ip4 = "(?:{$oct}\\.{$oct}\\.{$oct}\\.{$oct})"; 00035 } 00036 00037 } 00038 00039 // vim: et sw=4 sts=4