File indexing completed on 2025-01-26 05:29:07
0001 <?php 0002 0003 /** 0004 * XHTML 1.1 Legacy module defines elements that were previously 0005 * deprecated. 0006 * 0007 * @note Not all legacy elements have been implemented yet, which 0008 * is a bit of a reverse problem as compared to browsers! In 0009 * addition, this legacy module may implement a bit more than 0010 * mandated by XHTML 1.1. 0011 * 0012 * This module can be used in combination with TransformToStrict in order 0013 * to transform as many deprecated elements as possible, but retain 0014 * questionably deprecated elements that do not have good alternatives 0015 * as well as transform elements that don't have an implementation. 0016 * See docs/ref-strictness.txt for more details. 0017 */ 0018 0019 class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule 0020 { 0021 /** 0022 * @type string 0023 */ 0024 public $name = 'Legacy'; 0025 0026 /** 0027 * @param HTMLPurifier_Config $config 0028 */ 0029 public function setup($config) 0030 { 0031 $this->addElement( 0032 'basefont', 0033 'Inline', 0034 'Empty', 0035 null, 0036 array( 0037 'color' => 'Color', 0038 'face' => 'Text', // extremely broad, we should 0039 'size' => 'Text', // tighten it 0040 'id' => 'ID' 0041 ) 0042 ); 0043 $this->addElement('center', 'Block', 'Flow', 'Common'); 0044 $this->addElement( 0045 'dir', 0046 'Block', 0047 'Required: li', 0048 'Common', 0049 array( 0050 'compact' => 'Bool#compact' 0051 ) 0052 ); 0053 $this->addElement( 0054 'font', 0055 'Inline', 0056 'Inline', 0057 array('Core', 'I18N'), 0058 array( 0059 'color' => 'Color', 0060 'face' => 'Text', // extremely broad, we should 0061 'size' => 'Text', // tighten it 0062 ) 0063 ); 0064 $this->addElement( 0065 'menu', 0066 'Block', 0067 'Required: li', 0068 'Common', 0069 array( 0070 'compact' => 'Bool#compact' 0071 ) 0072 ); 0073 0074 $s = $this->addElement('s', 'Inline', 'Inline', 'Common'); 0075 $s->formatting = true; 0076 0077 $strike = $this->addElement('strike', 'Inline', 'Inline', 'Common'); 0078 $strike->formatting = true; 0079 0080 $u = $this->addElement('u', 'Inline', 'Inline', 'Common'); 0081 $u->formatting = true; 0082 0083 // setup modifications to old elements 0084 0085 $align = 'Enum#left,right,center,justify'; 0086 0087 $address = $this->addBlankElement('address'); 0088 $address->content_model = 'Inline | #PCDATA | p'; 0089 $address->content_model_type = 'optional'; 0090 $address->child = false; 0091 0092 $blockquote = $this->addBlankElement('blockquote'); 0093 $blockquote->content_model = 'Flow | #PCDATA'; 0094 $blockquote->content_model_type = 'optional'; 0095 $blockquote->child = false; 0096 0097 $br = $this->addBlankElement('br'); 0098 $br->attr['clear'] = 'Enum#left,all,right,none'; 0099 0100 $caption = $this->addBlankElement('caption'); 0101 $caption->attr['align'] = 'Enum#top,bottom,left,right'; 0102 0103 $div = $this->addBlankElement('div'); 0104 $div->attr['align'] = $align; 0105 0106 $dl = $this->addBlankElement('dl'); 0107 $dl->attr['compact'] = 'Bool#compact'; 0108 0109 for ($i = 1; $i <= 6; $i++) { 0110 $h = $this->addBlankElement("h$i"); 0111 $h->attr['align'] = $align; 0112 } 0113 0114 $hr = $this->addBlankElement('hr'); 0115 $hr->attr['align'] = $align; 0116 $hr->attr['noshade'] = 'Bool#noshade'; 0117 $hr->attr['size'] = 'Pixels'; 0118 $hr->attr['width'] = 'Length'; 0119 0120 $img = $this->addBlankElement('img'); 0121 $img->attr['align'] = 'IAlign'; 0122 $img->attr['border'] = 'Pixels'; 0123 $img->attr['hspace'] = 'Pixels'; 0124 $img->attr['vspace'] = 'Pixels'; 0125 0126 // figure out this integer business 0127 0128 $li = $this->addBlankElement('li'); 0129 $li->attr['value'] = new HTMLPurifier_AttrDef_Integer(); 0130 $li->attr['type'] = 'Enum#s:1,i,I,a,A,disc,square,circle'; 0131 0132 $ol = $this->addBlankElement('ol'); 0133 $ol->attr['compact'] = 'Bool#compact'; 0134 $ol->attr['start'] = new HTMLPurifier_AttrDef_Integer(); 0135 $ol->attr['type'] = 'Enum#s:1,i,I,a,A'; 0136 0137 $p = $this->addBlankElement('p'); 0138 $p->attr['align'] = $align; 0139 0140 $pre = $this->addBlankElement('pre'); 0141 $pre->attr['width'] = 'Number'; 0142 0143 // script omitted 0144 0145 $table = $this->addBlankElement('table'); 0146 $table->attr['align'] = 'Enum#left,center,right'; 0147 $table->attr['bgcolor'] = 'Color'; 0148 0149 $tr = $this->addBlankElement('tr'); 0150 $tr->attr['bgcolor'] = 'Color'; 0151 0152 $th = $this->addBlankElement('th'); 0153 $th->attr['bgcolor'] = 'Color'; 0154 $th->attr['height'] = 'Length'; 0155 $th->attr['nowrap'] = 'Bool#nowrap'; 0156 $th->attr['width'] = 'Length'; 0157 0158 $td = $this->addBlankElement('td'); 0159 $td->attr['bgcolor'] = 'Color'; 0160 $td->attr['height'] = 'Length'; 0161 $td->attr['nowrap'] = 'Bool#nowrap'; 0162 $td->attr['width'] = 'Length'; 0163 0164 $ul = $this->addBlankElement('ul'); 0165 $ul->attr['compact'] = 'Bool#compact'; 0166 $ul->attr['type'] = 'Enum#square,disc,circle'; 0167 0168 // "safe" modifications to "unsafe" elements 0169 // WARNING: If you want to add support for an unsafe, legacy 0170 // attribute, make a new TrustedLegacy module with the trusted 0171 // bit set appropriately 0172 0173 $form = $this->addBlankElement('form'); 0174 $form->content_model = 'Flow | #PCDATA'; 0175 $form->content_model_type = 'optional'; 0176 $form->attr['target'] = 'FrameTarget'; 0177 0178 $input = $this->addBlankElement('input'); 0179 $input->attr['align'] = 'IAlign'; 0180 0181 $legend = $this->addBlankElement('legend'); 0182 $legend->attr['align'] = 'LAlign'; 0183 } 0184 } 0185 0186 // vim: et sw=4 sts=4