35        $length = strlen($string);
 
   45        if ($length > 1 && $string[0] === 
'[' && $string[$length - 1] === 
']') {
 
   47            $ip = substr($string, 1, $length - 2);
 
   56        $ipv4 = $this->ipv4->validate($string, 
$config, $context);
 
   57        if (
$ipv4 !== 
false) {
 
   77        $underscore = 
$config->get(
'Core.AllowHostnameUnderscore') ? 
'_' : 
'';
 
   84        $and = 
"[a-z0-9-$underscore]"; 
 
   86        $domainlabel = 
"$an(?:$and*$an)?";
 
   90        $toplabel = 
"$an(?:$and*$an)?";
 
   92        if (preg_match(
"/^(?:$domainlabel\.)*($toplabel)\.?$/i", $string, $matches)) {
 
   93            if (!ctype_digit($matches[1])) {
 
   99        if (function_exists(
'idn_to_ascii')) {
 
  100            return idn_to_ascii($string);
 
  105        } elseif (
$config->get(
'Core.EnableIDNA')) {
 
  106            $idna = 
new Net_IDNA2(array(
'encoding' => 
'utf8', 
'overlong' => 
false, 
'strict' => 
true));
 
  108            $parts = explode(
'.', $string);
 
  110                $new_parts = array();
 
  111                foreach ($parts as $part) {
 
  113                    for ($i = 0, $c = strlen($part); $i < $c; $i++) {
 
  114                        if (ord($part[$i]) > 0x7a) {
 
  120                        $new_parts[] = $part;
 
  122                        $new_parts[] = $idna->encode($part);
 
  125                $string = implode(
'.', $new_parts);
 
  126                if (preg_match(
"/^($domainlabel\.)*$toplabel\.?$/i", $string)) {
 
  129            } 
catch (Exception $e) {
 
An exception for terminatinating execution or to throw for unit testing.
Validates a host according to the IPv4, IPv6 and DNS (future) specifications.
validate($string, $config, $context)
Validates an IPv4 address.
Validates an IPv6 address.
Base class for all validating attribute definitions.