Fix removal of id with DirectLex by preserving armor.
[htmlpurifier.git] / library / HTMLPurifier / Token / Tag.php
blobf4d8f640e60c26dca93911201d6a9b03b1a25798
1 <?php
3 /**
4 * Abstract class of a tag token (start, end or empty), and its behavior.
5 */
6 class HTMLPurifier_Token_Tag extends HTMLPurifier_Token
8 /**
9 * Static bool marker that indicates the class is a tag.
11 * This allows us to check objects with <tt>!empty($obj->is_tag)</tt>
12 * without having to use a function call <tt>is_a()</tt>.
14 public $is_tag = true;
16 /**
17 * The lower-case name of the tag, like 'a', 'b' or 'blockquote'.
19 * @note Strictly speaking, XML tags are case sensitive, so we shouldn't
20 * be lower-casing them, but these tokens cater to HTML tags, which are
21 * insensitive.
23 public $name;
25 /**
26 * Associative array of the tag's attributes.
28 public $attr = array();
30 /**
31 * Non-overloaded constructor, which lower-cases passed tag name.
33 * @param $name String name.
34 * @param $attr Associative array of attributes.
36 public function __construct($name, $attr = array(), $line = null, $col = null, $armor = array()) {
37 $this->name = ctype_lower($name) ? $name : strtolower($name);
38 foreach ($attr as $key => $value) {
39 // normalization only necessary when key is not lowercase
40 if (!ctype_lower($key)) {
41 $new_key = strtolower($key);
42 if (!isset($attr[$new_key])) {
43 $attr[$new_key] = $attr[$key];
45 if ($new_key !== $key) {
46 unset($attr[$key]);
50 $this->attr = $attr;
51 $this->line = $line;
52 $this->col = $col;
53 $this->armor = $armor;
57 // vim: et sw=4 sts=4