2007-03-29 23:19:53 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pre-transform that changes deprecated name attribute to ID if necessary
|
|
|
|
*/
|
|
|
|
class HTMLPurifier_AttrTransform_Name extends HTMLPurifier_AttrTransform
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
/**
|
|
|
|
* @param array $attr
|
|
|
|
* @param HTMLPurifier_Config $config
|
|
|
|
* @param HTMLPurifier_Context $context
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function transform($attr, $config, $context)
|
|
|
|
{
|
2009-03-20 23:34:38 +00:00
|
|
|
// Abort early if we're using relaxed definition of name
|
2013-07-16 11:56:14 +00:00
|
|
|
if ($config->get('HTML.Attr.Name.UseCDATA')) {
|
|
|
|
return $attr;
|
|
|
|
}
|
|
|
|
if (!isset($attr['name'])) {
|
|
|
|
return $attr;
|
|
|
|
}
|
2007-05-05 02:25:55 +00:00
|
|
|
$id = $this->confiscateAttr($attr, 'name');
|
2013-07-16 11:56:14 +00:00
|
|
|
if (isset($attr['id'])) {
|
|
|
|
return $attr;
|
|
|
|
}
|
2007-05-05 02:25:55 +00:00
|
|
|
$attr['id'] = $id;
|
2007-03-29 23:19:53 +00:00
|
|
|
return $attr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|