ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
HTMLPurifier_AttrDef_HTML_ID Class Reference

Validates the HTML attribute ID. More...

+ Inheritance diagram for HTMLPurifier_AttrDef_HTML_ID:
+ Collaboration diagram for HTMLPurifier_AttrDef_HTML_ID:

Public Member Functions

 __construct ($selector=false)
 validate ($id, $config, $context)
- Public Member Functions inherited from HTMLPurifier_AttrDef
 parseCDATA ($string)
 Convenience method that parses a string as if it were CDATA.
 make ($string)
 Factory method for creating this class from a string.

Protected Attributes

 $selector
 Determines whether or not we're validating an ID in a CSS selector context.

Additional Inherited Members

- Data Fields inherited from HTMLPurifier_AttrDef
 $minimized = false
 Tells us whether or not an HTML attribute is minimized.
 $required = false
 Tells us whether or not an HTML attribute is required.
- Protected Member Functions inherited from HTMLPurifier_AttrDef
 mungeRgb ($string)
 Removes spaces from rgb(0, 0, 0) so that shorthand CSS properties work properly.
 expandCSSEscape ($string)
 Parses a possibly escaped CSS string and returns the "pure" version of it.

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.

Constructor & Destructor Documentation

HTMLPurifier_AttrDef_HTML_ID::__construct (   $selector = false)
Parameters
bool$selector

Definition at line 28 of file ID.php.

References $selector.

{
$this->selector = $selector;
}

Member Function Documentation

HTMLPurifier_AttrDef_HTML_ID::validate (   $id,
  $config,
  $context 
)
Parameters
string$id
HTMLPurifier_Config$config
HTMLPurifier_Context$context
Returns
bool|string

Reimplemented from HTMLPurifier_AttrDef.

Definition at line 39 of file ID.php.

References $result.

{
if (!$this->selector && !$config->get('Attr.EnableID')) {
return false;
}
$id = trim($id); // trim it first
if ($id === '') {
return false;
}
$prefix = $config->get('Attr.IDPrefix');
if ($prefix !== '') {
$prefix .= $config->get('Attr.IDPrefixLocal');
// prevent re-appending the prefix
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
);
}
if (!$this->selector) {
$id_accumulator =& $context->get('IDAccumulator');
if (isset($id_accumulator->ids[$id])) {
return false;
}
}
// we purposely avoid using regex, hopefully this is faster
if (ctype_alpha($id)) {
$result = true;
} else {
if (!ctype_alpha(@$id[0])) {
return false;
}
// primitive style of regexps, I suppose
$trim = trim(
$id,
'A..Za..z0..9:-._'
);
$result = ($trim === '');
}
$regexp = $config->get('Attr.IDBlacklistRegexp');
if ($regexp && preg_match($regexp, $id)) {
return false;
}
if (!$this->selector && $result) {
$id_accumulator->add($id);
}
// if no change was made to the ID, return the result
// else, return the new id if stripping whitespace made it
// valid, or return false.
return $result ? $id : false;
}

Field Documentation

HTMLPurifier_AttrDef_HTML_ID::$selector
protected

Determines whether or not we're validating an ID in a CSS selector context.

bool

Definition at line 23 of file ID.php.

Referenced by __construct().


The documentation for this class was generated from the following file: