Name.php 587 B

123456789101112131415161718192021
  1. <?php
  2. /**
  3. * Pre-transform that changes deprecated name attribute to ID if necessary
  4. */
  5. class HTMLPurifier_AttrTransform_Name extends HTMLPurifier_AttrTransform
  6. {
  7. public function transform($attr, $config, $context) {
  8. // Abort early if we're using relaxed definition of name
  9. if ($config->get('HTML.Attr.Name.UseCDATA')) return $attr;
  10. if (!isset($attr['name'])) return $attr;
  11. $id = $this->confiscateAttr($attr, 'name');
  12. if ( isset($attr['id'])) return $attr;
  13. $attr['id'] = $id;
  14. return $attr;
  15. }
  16. }
  17. // vim: et sw=4 sts=4