Validates the HTML attribute ID.
More...
Public Member Functions |
| validate ($id, $config, $context) |
| Validates and cleans passed string according to a definition.
|
| parseCDATA ($string) |
| Convenience method that parses a string as if it were CDATA.
|
| make ($string) |
| Factory method for creating this class from a string.
|
Additional Inherited Members |
| $minimized = false |
| Tells us whether or not an HTML attribute is minimized.
|
| $required = false |
| Tells us whether or not an HTML attribute is required.
|
| mungeRgb ($string) |
| Removes spaces from rgb(0, 0, 0) so that shorthand CSS properties work properly.
|
Detailed Description
Validates the HTML attribute ID.
- Warning
- Even though this is the id processor, it will ignore the directive Attr:IDBlacklist, since it will only go according to the ID accumulator. Since the accumulator is automatically generated, it will have already absorbed the blacklist. If you're hacking around, make sure you use load()!
Definition at line 12 of file ID.php.
Member Function Documentation
HTMLPurifier_AttrDef_HTML_ID::validate |
( |
|
$string, |
|
|
|
$config, |
|
|
|
$context |
|
) |
| |
Validates and cleans passed string according to a definition.
- Parameters
-
$string | String to be validated and cleaned. |
$config | Mandatory HTMLPurifier_Config object. |
$context | Mandatory HTMLPurifier_AttrContext object. |
$this->ref &&
Reimplemented from HTMLPurifier_AttrDef.
Definition at line 18 of file ID.php.
References $config.
{
if (!
$config->get(
'Attr.EnableID'))
return false;
$id = trim($id);
if ($id === '') return false;
$prefix =
$config->get(
'Attr.IDPrefix');
if ($prefix !== '') {
$prefix .=
$config->get(
'Attr.IDPrefixLocal');
if (strpos($id, $prefix) !== 0) $id = $prefix . $id;
} elseif (
$config->get(
'Attr.IDPrefixLocal') !==
'') {
trigger_error('%Attr.IDPrefixLocal cannot be used unless '.
'%Attr.IDPrefix is set', E_USER_WARNING);
}
$id_accumulator =& $context->get('IDAccumulator');
if (isset($id_accumulator->ids[$id])) return false;
if (ctype_alpha($id)) {
$result = true;
} else {
if (!ctype_alpha(@$id[0])) return false;
$trim = trim(
$id,
'A..Za..z0..9:-._'
);
$result = ($trim === '');
}
$regexp =
$config->get(
'Attr.IDBlacklistRegexp');
if ($regexp && preg_match($regexp, $id)) {
return false;
}
if ($result) $id_accumulator->add($id);
return $result ? $id : false;
}
The documentation for this class was generated from the following file:
- Services/Html/HtmlPurifier/library/HTMLPurifier/AttrDef/HTML/ID.php