| 1: | <?php
|
| 2: |
|
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: |
|
| 8: | class HTMLPurifier_AttrTransform_NameSync extends HTMLPurifier_AttrTransform
|
| 9: | {
|
| 10: |
|
| 11: | |
| 12: | |
| 13: |
|
| 14: | public $idDef;
|
| 15: |
|
| 16: | public function __construct()
|
| 17: | {
|
| 18: | $this->idDef = new HTMLPurifier_AttrDef_HTML_ID();
|
| 19: | }
|
| 20: |
|
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: |
|
| 27: | public function transform($attr, $config, $context)
|
| 28: | {
|
| 29: | if (!isset($attr['name'])) {
|
| 30: | return $attr;
|
| 31: | }
|
| 32: | $name = $attr['name'];
|
| 33: | if (isset($attr['id']) && $attr['id'] === $name) {
|
| 34: | return $attr;
|
| 35: | }
|
| 36: | $result = $this->idDef->validate($name, $config, $context);
|
| 37: | if ($result === false) {
|
| 38: | unset($attr['name']);
|
| 39: | } else {
|
| 40: | $attr['name'] = $result;
|
| 41: | }
|
| 42: | return $attr;
|
| 43: | }
|
| 44: | }
|
| 45: |
|
| 46: |
|
| 47: | |