ILIAS  release_4-4 Revision
HTMLPurifier_AttrDef_HTML_LinkTypes Class Reference

Validates a rel/rev link attribute against a directive of allowed values. More...

+ Inheritance diagram for HTMLPurifier_AttrDef_HTML_LinkTypes:
+ Collaboration diagram for HTMLPurifier_AttrDef_HTML_LinkTypes:

Public Member Functions

 __construct ($name)
 
 validate ($string, $config, $context)
 
- Public Member Functions inherited from HTMLPurifier_AttrDef
 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...
 

Protected Attributes

 $name
 Name config attribute to pull. More...
 

Additional Inherited Members

- Data Fields inherited from HTMLPurifier_AttrDef
 $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...
 
- Protected Member Functions inherited from HTMLPurifier_AttrDef
 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...
 

Detailed Description

Validates a rel/rev link attribute against a directive of allowed values.

Note
We cannot use Enum because link types allow multiple values.
Assumes link types are ASCII text

Definition at line 9 of file LinkTypes.php.

Constructor & Destructor Documentation

◆ __construct()

HTMLPurifier_AttrDef_HTML_LinkTypes::__construct (   $name)

Definition at line 15 of file LinkTypes.php.

References $name.

15  {
16  $configLookup = array(
17  'rel' => 'AllowedRel',
18  'rev' => 'AllowedRev'
19  );
20  if (!isset($configLookup[$name])) {
21  trigger_error('Unrecognized attribute name for link '.
22  'relationship.', E_USER_ERROR);
23  return;
24  }
25  $this->name = $configLookup[$name];
26  }
$name
Name config attribute to pull.
Definition: LinkTypes.php:13

Member Function Documentation

◆ validate()

HTMLPurifier_AttrDef_HTML_LinkTypes::validate (   $string,
  $config,
  $context 
)

Definition at line 28 of file LinkTypes.php.

References HTMLPurifier_AttrDef\parseCDATA().

28  {
29 
30  $allowed = $config->get('Attr.' . $this->name);
31  if (empty($allowed)) return false;
32 
33  $string = $this->parseCDATA($string);
34  $parts = explode(' ', $string);
35 
36  // lookup to prevent duplicates
37  $ret_lookup = array();
38  foreach ($parts as $part) {
39  $part = strtolower(trim($part));
40  if (!isset($allowed[$part])) continue;
41  $ret_lookup[$part] = true;
42  }
43 
44  if (empty($ret_lookup)) return false;
45  $string = implode(' ', array_keys($ret_lookup));
46 
47  return $string;
48 
49  }
parseCDATA($string)
Convenience method that parses a string as if it were CDATA.
Definition: AttrDef.php:58
+ Here is the call graph for this function:

Field Documentation

◆ $name

HTMLPurifier_AttrDef_HTML_LinkTypes::$name
protected

Name config attribute to pull.

Definition at line 13 of file LinkTypes.php.

Referenced by __construct().


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