4 * Validates a rel/rev link attribute against a directive of allowed values
5 * @note We cannot use Enum because link types allow multiple
7 * @note Assumes link types are ASCII text
9 class HTMLPurifier_AttrDef_HTML_LinkTypes
extends HTMLPurifier_AttrDef
13 * Name config attribute to pull.
21 public function __construct($name)
23 $configLookup = array(
24 'rel' => 'AllowedRel',
27 if (!isset($configLookup[$name])) {
29 'Unrecognized attribute name for link ' .
35 $this->name
= $configLookup[$name];
39 * @param string $string
40 * @param HTMLPurifier_Config $config
41 * @param HTMLPurifier_Context $context
44 public function validate($string, $config, $context)
46 $allowed = $config->get('Attr.' . $this->name
);
47 if (empty($allowed)) {
51 $string = $this->parseCDATA($string);
52 $parts = explode(' ', $string);
54 // lookup to prevent duplicates
55 $ret_lookup = array();
56 foreach ($parts as $part) {
57 $part = strtolower(trim($part));
58 if (!isset($allowed[$part])) {
61 $ret_lookup[$part] = true;
64 if (empty($ret_lookup)) {
67 $string = implode(' ', array_keys($ret_lookup));