Validates a host according to the IPv4, IPv6 and DNS (future) specifications.
More...
|
| __construct () |
|
| validate ($string, $config, $context) |
|
| validate ($string, $config, $context) |
| Validates and cleans passed string according to a definition. More...
|
|
| parseCDATA ($string) |
| Convenience method that parses a string as if it were CDATA. More...
|
|
| make ($string) |
| Factory method for creating this class from a string. More...
|
|
|
| $minimized = false |
| Tells us whether or not an HTML attribute is minimized. More...
|
|
| $required = false |
| Tells us whether or not an HTML attribute is required. More...
|
|
| mungeRgb ($string) |
| Removes spaces from rgb(0, 0, 0) so that shorthand CSS properties work properly. More...
|
|
| expandCSSEscape ($string) |
| Parses a possibly escaped CSS string and returns the "pure" version of it. More...
|
|
Validates a host according to the IPv4, IPv6 and DNS (future) specifications.
Definition at line 6 of file Host.php.
◆ __construct()
HTMLPurifier_AttrDef_URI_Host::__construct |
( |
| ) |
|
Definition at line 21 of file Host.php.
Validates an IPv6 address.
Validates an IPv4 address.
◆ validate()
HTMLPurifier_AttrDef_URI_Host::validate |
( |
|
$string, |
|
|
|
$config, |
|
|
|
$context |
|
) |
| |
- Parameters
-
- Returns
- bool|string
Definition at line 33 of file Host.php.
References $ipv4, and $valid.
35 $length = strlen($string);
45 if ($length > 1 && $string[0] ===
'[' && $string[$length - 1] ===
']') {
47 $ip = substr($string, 1, $length - 2);
48 $valid = $this->ipv6->validate($ip, $config, $context);
56 $ipv4 = $this->ipv4->validate($string, $config, $context);
57 if (
$ipv4 !==
false) {
77 $underscore = $config->get(
'Core.AllowHostnameUnderscore') ?
'_' :
'';
82 $and =
"[a-z0-9-$underscore]";
84 $domainlabel =
"$an($and*$an)?";
86 $toplabel =
"$a($and*$an)?";
88 if (preg_match(
"/^($domainlabel\.)*$toplabel\.?$/i", $string)) {
96 if (function_exists(
'idn_to_ascii')) {
97 return idn_to_ascii($string);
101 } elseif ($config->get(
'Core.EnableIDNA')) {
103 $idna =
new Net_IDNA2(array(
'encoding' =>
'utf8',
'overlong' =>
false,
'strict' =>
true));
105 $parts = explode(
'.', $string);
107 $new_parts = array();
108 foreach ($parts as $part) {
110 for ($i = 0, $c = strlen($part); $i < $c; $i++) {
111 if (ord($part[$i]) > 0x7a) {
117 $new_parts[] = $part;
119 $new_parts[] = $idna->encode($part);
122 $string = implode(
'.', $new_parts);
123 if (preg_match(
"/^($domainlabel\.)*$toplabel\.?$/i", $string)) {
◆ $ipv4
HTMLPurifier_AttrDef_URI_Host::$ipv4 |
|
protected |
◆ $ipv6
HTMLPurifier_AttrDef_URI_Host::$ipv6 |
|
protected |
The documentation for this class was generated from the following file:
- Services/Html/HtmlPurifier/library/HTMLPurifier/AttrDef/URI/Host.php