ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
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)
Parameters
string$name

Definition at line 21 of file LinkTypes.php.

References $name.

22  {
23  $configLookup = array(
24  'rel' => 'AllowedRel',
25  'rev' => 'AllowedRev'
26  );
27  if (!isset($configLookup[$name])) {
28  trigger_error(
29  'Unrecognized attribute name for link ' .
30  'relationship.',
31  E_USER_ERROR
32  );
33  return;
34  }
35  $this->name = $configLookup[$name];
36  }
$name
Name config attribute to pull.
Definition: LinkTypes.php:16

Member Function Documentation

◆ validate()

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

Definition at line 44 of file LinkTypes.php.

References HTMLPurifier_AttrDef\parseCDATA().

45  {
46  $allowed = $config->get('Attr.' . $this->name);
47  if (empty($allowed)) {
48  return false;
49  }
50 
51  $string = $this->parseCDATA($string);
52  $parts = explode(' ', $string);
53 
54  // lookup to prevent duplicates
55  $ret_lookup = array();
56  foreach ($parts as $part) {
57  $part = strtolower(trim($part));
58  if (!isset($allowed[$part])) {
59  continue;
60  }
61  $ret_lookup[$part] = true;
62  }
63 
64  if (empty($ret_lookup)) {
65  return false;
66  }
67  $string = implode(' ', array_keys($ret_lookup));
68  return $string;
69  }
parseCDATA($string)
Convenience method that parses a string as if it were CDATA.
Definition: AttrDef.php:60
+ Here is the call graph for this function:

Field Documentation

◆ $name

HTMLPurifier_AttrDef_HTML_LinkTypes::$name
protected

Name config attribute to pull.

string

Definition at line 16 of file LinkTypes.php.

Referenced by __construct().


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