4 * XHTML 1.1 Legacy module defines elements that were previously
7 * @note Not all legacy elements have been implemented yet, which
8 * is a bit of a reverse problem as compared to browsers! In
9 * addition, this legacy module may implement a bit more than
10 * mandated by XHTML 1.1.
12 * This module can be used in combination with TransformToStrict in order
13 * to transform as many deprecated elements as possible, but retain
14 * questionably deprecated elements that do not have good alternatives
15 * as well as transform elements that don't have an implementation.
16 * See docs/ref-strictness.txt for more details.
19 class HTMLPurifier_HTMLModule_Legacy
extends HTMLPurifier_HTMLModule
24 public $name = 'Legacy';
27 * @param HTMLPurifier_Config $config
29 public function setup($config)
38 'face' => 'Text', // extremely broad, we should
39 'size' => 'Text', // tighten it
43 $this->addElement('center', 'Block', 'Flow', 'Common');
50 'compact' => 'Bool#compact'
57 array('Core', 'I18N'),
60 'face' => 'Text', // extremely broad, we should
61 'size' => 'Text', // tighten it
70 'compact' => 'Bool#compact'
74 $s = $this->addElement('s', 'Inline', 'Inline', 'Common');
75 $s->formatting
= true;
77 $strike = $this->addElement('strike', 'Inline', 'Inline', 'Common');
78 $strike->formatting
= true;
80 $u = $this->addElement('u', 'Inline', 'Inline', 'Common');
81 $u->formatting
= true;
83 // setup modifications to old elements
85 $align = 'Enum#left,right,center,justify';
87 $address = $this->addBlankElement('address');
88 $address->content_model
= 'Inline | #PCDATA | p';
89 $address->content_model_type
= 'optional';
90 $address->child
= false;
92 $blockquote = $this->addBlankElement('blockquote');
93 $blockquote->content_model
= 'Flow | #PCDATA';
94 $blockquote->content_model_type
= 'optional';
95 $blockquote->child
= false;
97 $br = $this->addBlankElement('br');
98 $br->attr
['clear'] = 'Enum#left,all,right,none';
100 $caption = $this->addBlankElement('caption');
101 $caption->attr
['align'] = 'Enum#top,bottom,left,right';
103 $div = $this->addBlankElement('div');
104 $div->attr
['align'] = $align;
106 $dl = $this->addBlankElement('dl');
107 $dl->attr
['compact'] = 'Bool#compact';
109 for ($i = 1; $i <= 6; $i++
) {
110 $h = $this->addBlankElement("h$i");
111 $h->attr
['align'] = $align;
114 $hr = $this->addBlankElement('hr');
115 $hr->attr
['align'] = $align;
116 $hr->attr
['noshade'] = 'Bool#noshade';
117 $hr->attr
['size'] = 'Pixels';
118 $hr->attr
['width'] = 'Length';
120 $img = $this->addBlankElement('img');
121 $img->attr
['align'] = 'IAlign';
122 $img->attr
['border'] = 'Pixels';
123 $img->attr
['hspace'] = 'Pixels';
124 $img->attr
['vspace'] = 'Pixels';
126 // figure out this integer business
128 $li = $this->addBlankElement('li');
129 $li->attr
['value'] = new HTMLPurifier_AttrDef_Integer();
130 $li->attr
['type'] = 'Enum#s:1,i,I,a,A,disc,square,circle';
132 $ol = $this->addBlankElement('ol');
133 $ol->attr
['compact'] = 'Bool#compact';
134 $ol->attr
['start'] = new HTMLPurifier_AttrDef_Integer();
135 $ol->attr
['type'] = 'Enum#s:1,i,I,a,A';
137 $p = $this->addBlankElement('p');
138 $p->attr
['align'] = $align;
140 $pre = $this->addBlankElement('pre');
141 $pre->attr
['width'] = 'Number';
145 $table = $this->addBlankElement('table');
146 $table->attr
['align'] = 'Enum#left,center,right';
147 $table->attr
['bgcolor'] = 'Color';
149 $tr = $this->addBlankElement('tr');
150 $tr->attr
['bgcolor'] = 'Color';
152 $th = $this->addBlankElement('th');
153 $th->attr
['bgcolor'] = 'Color';
154 $th->attr
['height'] = 'Length';
155 $th->attr
['nowrap'] = 'Bool#nowrap';
156 $th->attr
['width'] = 'Length';
158 $td = $this->addBlankElement('td');
159 $td->attr
['bgcolor'] = 'Color';
160 $td->attr
['height'] = 'Length';
161 $td->attr
['nowrap'] = 'Bool#nowrap';
162 $td->attr
['width'] = 'Length';
164 $ul = $this->addBlankElement('ul');
165 $ul->attr
['compact'] = 'Bool#compact';
166 $ul->attr
['type'] = 'Enum#square,disc,circle';
168 // "safe" modifications to "unsafe" elements
169 // WARNING: If you want to add support for an unsafe, legacy
170 // attribute, make a new TrustedLegacy module with the trusted
171 // bit set appropriately
173 $form = $this->addBlankElement('form');
174 $form->content_model
= 'Flow | #PCDATA';
175 $form->content_model_type
= 'optional';
176 $form->attr
['target'] = 'FrameTarget';
178 $input = $this->addBlankElement('input');
179 $input->attr
['align'] = 'IAlign';
181 $legend = $this->addBlankElement('legend');
182 $legend->attr
['align'] = 'LAlign';
186 // vim: et sw=4 sts=4