| 1: | <?php
|
| 2: |
|
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: |
|
| 9: | class HTMLPurifier_AttrDef_HTML_LinkTypes extends HTMLPurifier_AttrDef
|
| 10: | {
|
| 11: |
|
| 12: | |
| 13: | |
| 14: | |
| 15: |
|
| 16: | protected $name;
|
| 17: |
|
| 18: | |
| 19: | |
| 20: |
|
| 21: | public function __construct($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: | }
|
| 37: |
|
| 38: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: |
|
| 44: | public function validate($string, $config, $context)
|
| 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: |
|
| 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: | }
|
| 70: | }
|
| 71: |
|
| 72: |
|
| 73: | |