Parent Directory
|
Revision Log
|
Revision Graph
Initial commit of Beautify module. This module buffers the HTML output of Drupal and processes it through HTMLTidy, htmLawed or a set of built-in functions for beautifying (auto-indentation), flattening (removing indentations) and compacting the source code output to the browser.
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | htmLawed 1.1.1, 27 september 2008 |
| 5 | Copyright Santosh Patnaik |
| 6 | GPL v3 license |
| 7 | A PHP Labware internal utility; www.bioinformatics.org/phplabware/internal_utilities/htmLawed |
| 8 | |
| 9 | See htmLawed_README.txt/.htm |
| 10 | */ |
| 11 | |
| 12 | function htmLawed($t, $C=1, $spec=array()){ |
| 13 | $C = is_array($C) ? $C : array(); |
| 14 | if(!empty($C['valid_xhtml'])){ |
| 15 | $C['elements'] = empty($C['elements']) ? '*-center-dir-font-isindex-menu-s-strike-u' : $C['elements']; |
| 16 | $C['make_tag_strict'] = isset($C['make_tag_strict']) ? $C['make_tag_strict'] : 2; |
| 17 | $C['xml:lang'] = isset($C['xml:lang']) ? $C['xml:lang'] : 2; |
| 18 | } |
| 19 | // config eles |
| 20 | $e = array('a'=>1, 'abbr'=>1, 'acronym'=>1, 'address'=>1, 'applet'=>1, 'area'=>1, 'b'=>1, 'bdo'=>1, 'big'=>1, 'blockquote'=>1, 'br'=>1, 'button'=>1, 'caption'=>1, 'center'=>1, 'cite'=>1, 'code'=>1, 'col'=>1, 'colgroup'=>1, 'dd'=>1, 'del'=>1, 'dfn'=>1, 'dir'=>1, 'div'=>1, 'dl'=>1, 'dt'=>1, 'em'=>1, 'embed'=>1, 'fieldset'=>1, 'font'=>1, 'form'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'hr'=>1, 'i'=>1, 'iframe'=>1, 'img'=>1, 'input'=>1, 'ins'=>1, 'isindex'=>1, 'kbd'=>1, 'label'=>1, 'legend'=>1, 'li'=>1, 'map'=>1, 'menu'=>1, 'noscript'=>1, 'object'=>1, 'ol'=>1, 'optgroup'=>1, 'option'=>1, 'p'=>1, 'param'=>1, 'pre'=>1, 'q'=>1, 'rb'=>1, 'rbc'=>1, 'rp'=>1, 'rt'=>1, 'rtc'=>1, 'ruby'=>1, 's'=>1, 'samp'=>1, 'script'=>1, 'select'=>1, 'small'=>1, 'span'=>1, 'strike'=>1, 'strong'=>1, 'sub'=>1, 'sup'=>1, 'table'=>1, 'tbody'=>1, 'td'=>1, 'textarea'=>1, 'tfoot'=>1, 'th'=>1, 'thead'=>1, 'tr'=>1, 'tt'=>1, 'u'=>1, 'ul'=>1, 'var'=>1); // 86/deprecated+embed+ruby |
| 21 | if(!empty($C['safe'])){ |
| 22 | unset($e['applet'], $e['embed'], $e['iframe'], $e['object'], $e['script']); |
| 23 | } |
| 24 | $x = !empty($C['elements']) ? str_replace(array("\n", "\r", "\t", ' '), '', $C['elements']) : '*'; |
| 25 | if($x == '-*'){$e = array();} |
| 26 | elseif(strpos($x, '*') === false){$e = array_flip(explode(',', $x));} |
| 27 | else{ |
| 28 | if(isset($x[1])){ |
| 29 | preg_match_all('`(?:^|-|\+)[^\-+]+?(?=-|\+|$)`', $x, $m, PREG_SET_ORDER); |
| 30 | for($i=count($m); --$i>=0;){$m[$i] = $m[$i][0];} |
| 31 | foreach($m as $v){ |
| 32 | if($v[0] == '+'){$e[substr($v, 1)] = 1;} |
| 33 | if($v[0] == '-' && isset($e[($v = substr($v, 1))]) && !in_array('+'. $v, $m)){unset($e[$v]);} |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | $C['elements'] =& $e; |
| 38 | // config denied attrs |
| 39 | $C['deny_attribute'] = !empty($C['deny_attribute']) ? array_flip(explode(',', str_replace(array("\n", "\r", "\t", ' '), '', $C['deny_attribute']. (!empty($C['safe']) ? ',on*' : '')))) : (!empty($C['safe']) ? array('on*'=>1) : array()); |
| 40 | if(isset($C['deny_attribute']['on*'])){ |
| 41 | unset($C['deny_attribute']['on*']); |
| 42 | $C['deny_attribute'] += array('onblur'=>1, 'onchange'=>1, 'onclick'=>1, 'ondblclick'=>1, 'onfocus'=>1, 'onkeydown'=>1, 'onkeypress'=>1, 'onkeyup'=>1, 'onmousedown'=>1, 'onmousemove'=>1, 'onmouseout'=>1, 'onmouseover'=>1, 'onmouseup'=>1, 'onreset'=>1, 'onselect'=>1, 'onsubmit'=>1); |
| 43 | } |
| 44 | // config URL |
| 45 | $x = (isset($C['schemes'][2]) && strpos($C['schemes'], ':')) ? strtolower($C['schemes']) : 'href: aim, feed, file, ftp, gopher, http, https, irc, mailto, news, nntp, sftp, ssh, telnet; *:file, http, https'; |
| 46 | $C['schemes'] = array(); |
| 47 | foreach(explode(';', str_replace(array(' ', "\t", "\r", "\n"), '', $x)) as $v){ |
| 48 | $x = $x2 = null; list($x, $x2) = explode(':', $v, 2); |
| 49 | if($x2){$C['schemes'][$x] = array_flip(explode(',', $x2));} |
| 50 | } |
| 51 | if(!isset($C['schemes']['*'])){$C['schemes']['*'] = array('file'=>1, 'http'=>1, 'https'=>1,);} |
| 52 | if(!empty($C['safe']) && empty($C['schemes']['style'])){$C['schemes']['style'] = array('nil'=>1);} |
| 53 | $C['abs_url'] = isset($C['abs_url']) ? $C['abs_url'] : 0; |
| 54 | if(!isset($C['base_url']) or !preg_match('`^[a-zA-Z\d.+\-]+://[^/]+/(.+?/)?$`', $C['base_url'])){ |
| 55 | $C['base_url'] = $C['abs_url'] = 0; |
| 56 | } |
| 57 | // config rest |
| 58 | $C['and_mark'] = empty($C['and_mark']) ? 0 : 1; |
| 59 | $C['anti_link_spam'] = (isset($C['anti_link_spam']) && is_array($C['anti_link_spam']) && count($C['anti_link_spam']) == 2 && (empty($C['anti_link_spam'][0]) or hl_regex($C['anti_link_spam'][0])) && (empty($C['anti_link_spam'][1]) or hl_regex($C['anti_link_spam'][1]))) ? $C['anti_link_spam'] : 0; |
| 60 | $C['anti_mail_spam'] = isset($C['anti_mail_spam']) ? $C['anti_mail_spam'] : 0; |
| 61 | $C['balance'] = isset($C['balance']) ? (bool)$C['balance'] : 1; |
| 62 | $C['cdata'] = isset($C['cdata']) ? $C['cdata'] : (empty($C['safe']) ? 3 : 0); |
| 63 | $C['clean_ms_char'] = empty($C['clean_ms_char']) ? 0 : $C['clean_ms_char']; |
| 64 | $C['comment'] = isset($C['comment']) ? $C['comment'] : (empty($C['safe']) ? 3 : 0); |
| 65 | $C['css_expression'] = empty($C['css_expression']) ? 0 : 1; |
| 66 | $C['hexdec_entity'] = isset($C['hexdec_entity']) ? $C['hexdec_entity'] : 1; |
| 67 | $C['hook'] = (!empty($C['hook']) && function_exists($C['hook'])) ? $C['hook'] : 0; |
| 68 | $C['hook_tag'] = (!empty($C['hook_tag']) && function_exists($C['hook_tag'])) ? $C['hook_tag'] : 0; |
| 69 | $C['keep_bad'] = isset($C['keep_bad']) ? $C['keep_bad'] : 6; |
| 70 | $C['lc_std_val'] = isset($C['lc_std_val']) ? (bool)$C['lc_std_val'] : 1; |
| 71 | $C['make_tag_strict'] = isset($C['make_tag_strict']) ? $C['make_tag_strict'] : 1; |
| 72 | $C['named_entity'] = isset($C['named_entity']) ? (bool)$C['named_entity'] : 1; |
| 73 | $C['no_deprecated_attr'] = isset($C['no_deprecated_attr']) ? $C['no_deprecated_attr'] : 1; |
| 74 | $C['parent'] = isset($C['parent'][0]) ? strtolower($C['parent']) : 'body'; |
| 75 | $C['show_setting'] = !empty($C['show_setting']) ? $C['show_setting'] : 0; |
| 76 | $C['tidy'] = empty($C['tidy']) ? 0 : $C['tidy']; |
| 77 | $C['unique_ids'] = isset($C['unique_ids']) ? $C['unique_ids'] : 1; |
| 78 | $C['xml:lang'] = isset($C['xml:lang']) ? $C['xml:lang'] : 0; |
| 79 | |
| 80 | if(isset($GLOBALS['C'])){$reC = $GLOBALS['C'];} |
| 81 | $GLOBALS['C'] = $C; |
| 82 | $spec = is_array($spec) ? $spec : hl_spec($spec); |
| 83 | if(isset($GLOBALS['spec'])){$reSpec = $GLOBALS['spec'];} |
| 84 | $GLOBALS['spec'] = $spec; |
| 85 | |
| 86 | $t = preg_replace('`[\x00-\x08\x0b-\x0c\x0e-\x1f]`', '', $t); |
| 87 | if($C['clean_ms_char']){ |
| 88 | $x = array("\x7f"=>'', "\x80"=>'€', "\x81"=>'', "\x83"=>'ƒ', "\x85"=>'…', "\x86"=>'†', "\x87"=>'‡', "\x88"=>'ˆ', "\x89"=>'‰', "\x8a"=>'Š', "\x8b"=>'‹', "\x8c"=>'Œ', "\x8d"=>'', "\x8e"=>'Ž', "\x8f"=>'', "\x90"=>'', "\x95"=>'•', "\x96"=>'–', "\x97"=>'—', "\x98"=>'˜', "\x99"=>'™', "\x9a"=>'š', "\x9b"=>'›', "\x9c"=>'œ', "\x9d"=>'', "\x9e"=>'ž', "\x9f"=>'Ÿ'); |
| 89 | $x = $x + ($C['clean_ms_char'] == 1 ? array("\x82"=>'‚', "\x84"=>'„', "\x91"=>'‘', "\x92"=>'’', "\x93"=>'“', "\x94"=>'”') : array("\x82"=>'\'', "\x84"=>'"', "\x91"=>'\'', "\x92"=>'\'', "\x93"=>'"', "\x94"=>'"')); |
| 90 | $t = strtr($t, $x); |
| 91 | } |
| 92 | if($C['cdata'] or $C['comment']){$t = preg_replace_callback('`<!(?:(?:--.*?--)|(?:\[CDATA\[.*?\]\]))>`sm', 'hl_cmtcd', $t);} |
| 93 | $t = preg_replace_callback('`&([A-Za-z][A-Za-z0-9]{1,30}|#(?:[0-9]{1,8}|[Xx][0-9A-Fa-f]{1,7}));`', 'hl_ent', str_replace('&', '&', $t)); |
| 94 | if($C['unique_ids'] && !isset($GLOBALS['hl_Ids'])){$GLOBALS['hl_Ids'] = array();} |
| 95 | if($C['hook']){$t = $C['hook']($t, $C, $spec);} |
| 96 | if($C['show_setting'] && preg_match('`^[a-z][a-z0-9_]*$`i', $C['show_setting'])){ |
| 97 | $GLOBALS[$C['show_setting']] = array('config'=>$C, 'spec'=>$spec, 'time'=>microtime()); |
| 98 | } |
| 99 | // main |
| 100 | $t = preg_replace_callback('`<(?:(?:\s|$)|(?:[^>]*(?:>|$)))|>`m', 'hl_tag', $t); |
| 101 | $t = $C['balance'] ? hl_bal($t, $C['keep_bad'], $C['parent']) : $t; |
| 102 | $t = (($C['cdata'] or $C['comment']) && strpos($t, "\x01") !== false) ? str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05"), array('', '', '&', '<', '>'), $t) : $t; |
| 103 | $t = $C['tidy'] ? hl_tidy($t, $C['tidy'], $C['parent']) : $t; |
| 104 | unset($C, $e); |
| 105 | if(isset($reC)){$GLOBALS['C'] = $reC;} |
| 106 | if(isset($reSpec)){$GLOBALS['spec'] = $reSpec;} |
| 107 | return $t; |
| 108 | // eof |
| 109 | } |
| 110 | |
| 111 | function hl_attrval($t, $p){ |
| 112 | // check attr val against user spec |
| 113 | $o = 1; $l = strlen($t); |
| 114 | foreach($p as $k=>$v){ |
| 115 | switch($k){ |
| 116 | case 'maxlen':if($l > $v){$o = 0;} |
| 117 | break; case 'minlen': if($l < $v){$o = 0;} |
| 118 | break; case 'maxval': if((float)($t) > $v){$o = 0;} |
| 119 | break; case 'minval': if((float)($t) < $v){$o = 0;} |
| 120 | break; case 'match': if(!preg_match($v, $t)){$o = 0;} |
| 121 | break; case 'nomatch': if(preg_match($v, $t)){$o = 0;} |
| 122 | break; case 'oneof': |
| 123 | $m = 0; |
| 124 | foreach(explode('|', $v) as $n){if($t == $n){$m = 1; break;}} |
| 125 | $o = $m; |
| 126 | break; case 'noneof': |
| 127 | $m = 1; |
| 128 | foreach(explode('|', $v) as $n){if($t == $n){$m = 0; break;}} |
| 129 | $o = $m; |
| 130 | break; default: |
| 131 | break; |
| 132 | } |
| 133 | if(!$o){break;} |
| 134 | } |
| 135 | return ($o ? $t : (isset($p['default']) ? $p['default'] : 0)); |
| 136 | // eof |
| 137 | } |
| 138 | |
| 139 | function hl_bal($t, $do=1, $in='div'){ |
| 140 | // balance tags |
| 141 | // eles by content |
| 142 | $cB = array('blockquote'=>1, 'form'=>1, 'map'=>1, 'noscript'=>1); // Block |
| 143 | $cE = array('area'=>1, 'br'=>1, 'col'=>1, 'embed'=>1, 'hr'=>1, 'img'=>1, 'input'=>1, 'isindex'=>1, 'param'=>1); // Empty |
| 144 | $cF = array('button'=>1, 'del'=>1, 'div'=>1, 'dd'=>1, 'fieldset'=>1, 'iframe'=>1, 'ins'=>1, 'li'=>1, 'noscript'=>1, 'object'=>1, 'td'=>1, 'th'=>1); // Flow; later context-wise dynamic move of ins & del to $cI |
| 145 | $cI = array('a'=>1, 'abbr'=>1, 'acronym'=>1, 'address'=>1, 'b'=>1, 'bdo'=>1, 'big'=>1, 'caption'=>1, 'cite'=>1, 'code'=>1, 'dfn'=>1, 'dt'=>1, 'em'=>1, 'font'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'i'=>1, 'kbd'=>1, 'label'=>1, 'legend'=>1, 'p'=>1, 'pre'=>1, 'q'=>1, 'rb'=>1, 'rt'=>1, 's'=>1, 'samp'=>1, 'small'=>1, 'span'=>1, 'strike'=>1, 'strong'=>1, 'sub'=>1, 'sup'=>1, 'tt'=>1, 'u'=>1, 'var'=>1); // Inline |
| 146 | $cN = array('a'=>array('a'=>1), 'button'=>array('a'=>1, 'button'=>1, 'fieldset'=>1, 'form'=>1, 'iframe'=>1, 'input'=>1, 'label'=>1, 'select'=>1, 'textarea'=>1), 'fieldset'=>array('fieldset'=>1), 'form'=>array('form'=>1), 'label'=>array('label'=>1), 'noscript'=>array('script'=>1), 'pre'=>array('big'=>1, 'font'=>1, 'img'=>1, 'object'=>1, 'script'=>1, 'small'=>1, 'sub'=>1, 'sup'=>1), 'rb'=>array('ruby'=>1), 'rt'=>array('ruby'=>1)); // Illegal |
| 147 | $cN2 = array_keys($cN); |
| 148 | $cR = array('blockquote'=>1, 'dir'=>1, 'dl'=>1, 'form'=>1, 'map'=>1, 'menu'=>1, 'noscript'=>1, 'ol'=>1, 'optgroup'=>1, 'rbc'=>1, 'rtc'=>1, 'ruby'=>1, 'select'=>1, 'table'=>1, 'tbody'=>1, 'tfoot'=>1, 'thead'=>1, 'tr'=>1, 'ul'=>1); |
| 149 | $cS = array('colgroup'=>array('col'=>1), 'dir'=>array('li'), 'dl'=>array('dd'=>1, 'dt'=>1), 'menu'=>array('li'=>1), 'ol'=>array('li'=>1), 'optgroup'=>array('option'=>1), 'option'=>array('#pcdata'=>1), 'rbc'=>array('rb'=>1), 'rp'=>array('#pcdata'=>1), 'rtc'=>array('rt'=>1), 'ruby'=>array('rb'=>1, 'rbc'=>1, 'rp'=>1, 'rt'=>1, 'rtc'=>1), 'select'=>array('optgroup'=>1, 'option'=>1), 'script'=>array('#pcdata'=>1), 'table'=>array('caption'=>1, 'col'=>1, 'colgroup'=>1, 'tfoot'=>1, 'tbody'=>1, 'tr'=>1, 'thead'=>1), 'tbody'=>array('tr'=>1), 'tfoot'=>array('tr'=>1), 'textarea'=>array('#pcdata'=>1), 'thead'=>array('tr'=>1), 'tr'=>array('td'=>1, 'th'=>1), 'ul'=>array('li'=>1)); // Specific (immediate parent-child) |
| 150 | $cO = array('address'=>array('p'=>1), 'applet'=>array('param'=>1), 'blockquote'=>array('script'=>1), 'fieldset'=>array('legend'=>1, '#pcdata'=>1), 'form'=>array('script'=>1), 'map'=>array('area'=>1), 'object'=>array('param'=>1, 'embed'=>1)); // Other |
| 151 | $cT = array('colgroup'=>1, 'dd'=>1, 'dt'=>1, 'li'=>1, 'option'=>1, 'p'=>1, 'td'=>1, 'tfoot'=>1, 'th'=>1, 'thead'=>1, 'tr'=>1); // Omitable closing |
| 152 | // eles by block/inline type; ins & del both type; #pcdata: plain text |
| 153 | $eB = array('address'=>1, 'blockquote'=>1, 'center'=>1, 'del'=>1, 'dir'=>1, 'dl'=>1, 'div'=>1, 'fieldset'=>1, 'form'=>1, 'ins'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'hr'=>1, 'isindex'=>1, 'menu'=>1, 'noscript'=>1, 'ol'=>1, 'p'=>1, 'pre'=>1, 'table'=>1, 'ul'=>1); |
| 154 | $eI = array('#pcdata'=>1, 'a'=>1, 'abbr'=>1, 'acronym'=>1, 'applet'=>1, 'b'=>1, 'bdo'=>1, 'big'=>1, 'br'=>1, 'button'=>1, 'cite'=>1, 'code'=>1, 'del'=>1, 'dfn'=>1, 'em'=>1, 'embed'=>1, 'font'=>1, 'i'=>1, 'iframe'=>1, 'img'=>1, 'input'=>1, 'ins'=>1, 'kbd'=>1, 'label'=>1, 'map'=>1, 'object'=>1, 'param'=>1, 'q'=>1, 'ruby'=>1, 's'=>1, 'samp'=>1, 'select'=>1, 'script'=>1, 'small'=>1, 'span'=>1, 'strike'=>1, 'strong'=>1, 'sub'=>1, 'sup'=>1, 'textarea'=>1, 'tt'=>1, 'u'=>1, 'var'=>1); |
| 155 | $eN = array('a'=>1, 'big'=>1, 'button'=>1, 'fieldset'=>1, 'font'=>1, 'form'=>1, 'iframe'=>1, 'img'=>1, 'input'=>1, 'label'=>1, 'object'=>1, 'ruby'=>1, 'script'=>1, 'select'=>1, 'small'=>1, 'sub'=>1, 'sup'=>1, 'textarea'=>1); // Exclude from specific ele; $cN values |
| 156 | $eO = array('area'=>1, 'caption'=>1, 'col'=>1, 'colgroup'=>1, 'dd'=>1, 'dt'=>1, 'legend'=>1, 'li'=>1, 'optgroup'=>1, 'option'=>1, 'rb'=>1, 'rbc'=>1, 'rp'=>1, 'rt'=>1, 'rtc'=>1, 'script'=>1, 'tbody'=>1, 'td'=>1, 'tfoot'=>1, 'thead'=>1, 'th'=>1, 'tr'=>1); // Missing in $eB & $eI |
| 157 | $eF = $eB + $eI; |
| 158 | |
| 159 | // $in sets allowed children |
| 160 | $in = ((isset($eF[$in]) && $in != '#pcdata') or isset($eO[$in])) ? $in : 'div'; |
| 161 | if(isset($cE[$in])){ |
| 162 | return (!$do ? '' : str_replace(array('<', '>'), array('<', '>'), $t)); |
| 163 | } |
| 164 | if(isset($cS[$in])){$inOk = $cS[$in];} |
| 165 | elseif(isset($cI[$in])){$inOk = $eI; $cI['del'] = 1; $cI['ins'] = 1;} |
| 166 | elseif(isset($cF[$in])){$inOk = $eF; unset($cI['del'], $cI['ins']);} |
| 167 | elseif(isset($cB[$in])){$inOk = $eB; unset($cI['del'], $cI['ins']);} |
| 168 | if(isset($cO[$in])){$inOk = $inOk + $cO[$in];} |
| 169 | if(isset($cN[$in])){$inOk = array_diff_assoc($inOk, $cN[$in]);} |
| 170 | |
| 171 | $t = explode('<', $t); |
| 172 | $ok = $q = array(); // $q seq list of open non-empty ele |
| 173 | ob_start(); |
| 174 | |
| 175 | for($i=-1, $ci=count($t); ++$i<$ci;){ |
| 176 | // allowed $ok in parent $p |
| 177 | if($ql = count($q)){ |
| 178 | $p = array_pop($q); |
| 179 | $q[] = $p; |
| 180 | if(isset($cS[$p])){$ok = $cS[$p];} |
| 181 | elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} |
| 182 | elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} |
| 183 | elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} |
| 184 | if(isset($cO[$p])){$ok = $ok + $cO[$p];} |
| 185 | if(isset($cN[$p])){$ok = array_diff_assoc($ok, $cN[$p]);} |
| 186 | }else{$ok = $inOk; unset($cI['del'], $cI['ins']);} |
| 187 | // bad tags, & ele content |
| 188 | if(isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))){ |
| 189 | echo '<', $s, $e, $a, '>'; |
| 190 | } |
| 191 | if(isset($x[0])){ |
| 192 | if($do < 3 or isset($ok['#pcdata'])){echo $x;} |
| 193 | elseif(strpos($x, "\x02\x04")){ |
| 194 | foreach(preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v){ |
| 195 | echo (substr($v, 0, 2) == "\x01\x02" ? $v : ($do > 4 ? preg_replace('`\S`', '', $v) : '')); |
| 196 | } |
| 197 | }elseif($do > 4){echo preg_replace('`\S`', '', $x);} |
| 198 | } |
| 199 | // get markup |
| 200 | if(!preg_match('`^(/?)([a-zA-Z1-6]+)([^>]*)>(.*)`sm', $t[$i], $r)){$x = $t[$i]; continue;} |
| 201 | $s = null; $e = null; $a = null; $x = null; list($all, $s, $e, $a, $x) = $r; |
| 202 | // close tag |
| 203 | if($s){ |
| 204 | if(isset($cE[$e]) or !in_array($e, $q)){continue;} // Empty/unopen |
| 205 | if($p == $e){array_pop($q); echo '</', $e, '>'; unset($e); continue;} // Last open |
| 206 | $add = ''; // Nesting - close open tags that need to be |
| 207 | for($j=-1, $cj=count($q); ++$j<$cj;){ |
| 208 | if(($d = array_pop($q)) == $e){break;} |
| 209 | else{$add .= "</{$d}>";} |
| 210 | } |
| 211 | echo $add, '</', $e, '>'; unset($e); continue; |
| 212 | } |
| 213 | // open tag |
| 214 | // $cB ele needs $eB ele as child |
| 215 | if(isset($cB[$e]) && strlen(trim($x))){ |
| 216 | $t[$i] = "{$e}{$a}>"; |
| 217 | array_splice($t, $i+1, 0, 'div>'. $x); unset($e, $x); ++$ci; --$i; continue; |
| 218 | } |
| 219 | if((($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql)) && !isset($eB[$e]) && !isset($ok[$e])){ |
| 220 | array_splice($t, $i, 0, 'div>'); unset($e, $x); ++$ci; --$i; continue; |
| 221 | } |
| 222 | // if no open ele, $in is parent; except for certain cases, immediate parent-child relation should hold |
| 223 | if(!$ql or !isset($eN[$e]) or !array_intersect($q, $cN2)){ |
| 224 | if(!isset($ok[$e])){ |
| 225 | if($ql && isset($cT[$p])){echo '</', array_pop($q), '>'; unset($e, $x); --$i;} |
| 226 | continue; |
| 227 | } |
| 228 | if(!isset($cE[$e])){$q[] = $e;} |
| 229 | echo '<', $e, $a, '>'; unset($e); continue; |
| 230 | } |
| 231 | // specific parent-child |
| 232 | if(isset($cS[$p][$e])){ |
| 233 | if(!isset($cE[$e])){$q[] = $e;} |
| 234 | echo '<', $e, $a, '>'; unset($e); continue; |
| 235 | } |
| 236 | // nesting |
| 237 | $add = ''; |
| 238 | $q2 = array(); |
| 239 | for($k=-1, $kc=count($q); ++$k<$kc;){ |
| 240 | $d = $q[$k]; |
| 241 | $ok2 = array(); |
| 242 | if(isset($cS[$d])){$q2[] = $d; continue;} |
| 243 | $ok2 = isset($cI[$d]) ? $eI : $eF; |
| 244 | if(isset($cO[$d])){$ok2 = $ok2 + $cO[$d];} |
| 245 | if(isset($cN[$d])){$ok2 = array_diff_assoc($ok2, $cN[$d]);} |
| 246 | if(!isset($ok2[$e])){ |
| 247 | if(!$k && !isset($inOk[$e])){continue 2;} |
| 248 | $add = "</{$d}>"; |
| 249 | for(;++$k<$kc;){$add = "</{$q[$k]}>{$add}";} |
| 250 | break; |
| 251 | } |
| 252 | else{$q2[] = $d;} |
| 253 | } |
| 254 | $q = $q2; |
| 255 | if(!isset($cE[$e])){$q[] = $e;} |
| 256 | echo $add, '<', $e, $a, '>'; unset($e); continue; |
| 257 | } |
| 258 | |
| 259 | // end |
| 260 | if($ql = count($q)){ |
| 261 | $p = array_pop($q); |
| 262 | $q[] = $p; |
| 263 | if(isset($cS[$p])){$ok = $cS[$p];} |
| 264 | elseif(isset($cI[$p])){$ok = $eI; $cI['del'] = 1; $cI['ins'] = 1;} |
| 265 | elseif(isset($cF[$p])){$ok = $eF; unset($cI['del'], $cI['ins']);} |
| 266 | elseif(isset($cB[$p])){$ok = $eB; unset($cI['del'], $cI['ins']);} |
| 267 | if(isset($cO[$p])){$ok = $ok + $cO[$p];} |
| 268 | if(isset($cN[$p])){$ok = array_diff_assoc($ok, $cN[$p]);} |
| 269 | }else{$ok = $inOk; unset($cI['del'], $cI['ins']);} |
| 270 | if(isset($e) && ($do == 1 or (isset($ok['#pcdata']) && ($do == 3 or $do == 5)))){ |
| 271 | echo '<', $s, $e, $a, '>'; |
| 272 | } |
| 273 | if(isset($x[0])){ |
| 274 | if(strlen(trim($x)) && (($ql && isset($cB[$p])) or (isset($cB[$in]) && !$ql))){ |
| 275 | echo '<div>', $x, '</div>'; |
| 276 | } |
| 277 | elseif($do < 3 or isset($ok['#pcdata'])){echo $x;} |
| 278 | elseif(strpos($x, "\x02\x04")){ |
| 279 | foreach(preg_split('`(\x01\x02[^\x01\x02]+\x02\x01)`', $x, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $v){ |
| 280 | echo (substr($v, 0, 2) == "\x01\x02" ? $v : ($do > 4 ? preg_replace('`\S`', '', $v) : '')); |
| 281 | } |
| 282 | }elseif($do > 4){echo preg_replace('`\S`', '', $x);} |
| 283 | } |
| 284 | while(!empty($q) && ($e = array_pop($q))){echo '</', $e, '>';} |
| 285 | $o = ob_get_contents(); |
| 286 | ob_end_clean(); |
| 287 | return $o; |
| 288 | // eof |
| 289 | } |
| 290 | |
| 291 | function hl_cmtcd($t){ |
| 292 | // comment/CDATA sec handler |
| 293 | $t = $t[0]; |
| 294 | global $C; |
| 295 | if($t[3] == '-'){ |
| 296 | if(!$C['comment']){return $t;} |
| 297 | if($C['comment'] == 1){return '';} |
| 298 | if(substr(($t = preg_replace('`--+`', '-', substr($t, 4, -3))), -1) != ' '){$t .= ' ';} |
| 299 | $t = $C['comment'] == 2 ? str_replace(array('&', '<', '>'), array('&', '<', '>'), $t) : $t; |
| 300 | $t = "\x01\x02\x04!--$t--\x05\x02\x01"; |
| 301 | }else{ // CDATA |
| 302 | if(!$C['cdata']){return $t;} |
| 303 | if($C['cdata'] == 1){return '';} |
| 304 | $t = substr($t, 1, -1); |
| 305 | $t = $C['cdata'] == 2 ? str_replace(array('&', '<', '>'), array('&', '<', '>'), $t) : $t; |
| 306 | $t = "\x01\x01\x04$t\x05\x01\x01"; |
| 307 | } |
| 308 | return str_replace(array('&', '<', '>'), array("\x03", "\x04", "\x05"), $t); |
| 309 | // eof |
| 310 | } |
| 311 | |
| 312 | function hl_ent($t){ |
| 313 | // entitity handler |
| 314 | global $C; |
| 315 | $t = $t[1]; |
| 316 | static $U = array('quot'=>1,'amp'=>1,'lt'=>1,'gt'=>1); |
| 317 | static $N = array('fnof'=>'402', 'Alpha'=>'913', 'Beta'=>'914', 'Gamma'=>'915', 'Delta'=>'916', 'Epsilon'=>'917', 'Zeta'=>'918', 'Eta'=>'919', 'Theta'=>'920', 'Iota'=>'921', 'Kappa'=>'922', 'Lambda'=>'923', 'Mu'=>'924', 'Nu'=>'925', 'Xi'=>'926', 'Omicron'=>'927', 'Pi'=>'928', 'Rho'=>'929', 'Sigma'=>'931', 'Tau'=>'932', 'Upsilon'=>'933', 'Phi'=>'934', 'Chi'=>'935', 'Psi'=>'936', 'Omega'=>'937', 'alpha'=>'945', 'beta'=>'946', 'gamma'=>'947', 'delta'=>'948', 'epsilon'=>'949', 'zeta'=>'950', 'eta'=>'951', 'theta'=>'952', 'iota'=>'953', 'kappa'=>'954', 'lambda'=>'955', 'mu'=>'956', 'nu'=>'957', 'xi'=>'958', 'omicron'=>'959', 'pi'=>'960', 'rho'=>'961', 'sigmaf'=>'962', 'sigma'=>'963', 'tau'=>'964', 'upsilon'=>'965', 'phi'=>'966', 'chi'=>'967', 'psi'=>'968', 'omega'=>'969', 'thetasym'=>'977', 'upsih'=>'978', 'piv'=>'982', 'bull'=>'8226', 'hellip'=>'8230', 'prime'=>'8242', 'Prime'=>'8243', 'oline'=>'8254', 'frasl'=>'8260', 'weierp'=>'8472', 'image'=>'8465', 'real'=>'8476', 'trade'=>'8482', 'alefsym'=>'8501', 'larr'=>'8592', 'uarr'=>'8593', 'rarr'=>'8594', 'darr'=>'8595', 'harr'=>'8596', 'crarr'=>'8629', 'lArr'=>'8656', 'uArr'=>'8657', 'rArr'=>'8658', 'dArr'=>'8659', 'hArr'=>'8660', 'forall'=>'8704', 'part'=>'8706', 'exist'=>'8707', 'empty'=>'8709', 'nabla'=>'8711', 'isin'=>'8712', 'notin'=>'8713', 'ni'=>'8715', 'prod'=>'8719', 'sum'=>'8721', 'minus'=>'8722', 'lowast'=>'8727', 'radic'=>'8730', 'prop'=>'8733', 'infin'=>'8734', 'ang'=>'8736', 'and'=>'8743', 'or'=>'8744', 'cap'=>'8745', 'cup'=>'8746', 'int'=>'8747', 'there4'=>'8756', 'sim'=>'8764', 'cong'=>'8773', 'asymp'=>'8776', 'ne'=>'8800', 'equiv'=>'8801', 'le'=>'8804', 'ge'=>'8805', 'sub'=>'8834', 'sup'=>'8835', 'nsub'=>'8836', 'sube'=>'8838', 'supe'=>'8839', 'oplus'=>'8853', 'otimes'=>'8855', 'perp'=>'8869', 'sdot'=>'8901', 'lceil'=>'8968', 'rceil'=>'8969', 'lfloor'=>'8970', 'rfloor'=>'8971', 'lang'=>'9001', 'rang'=>'9002', 'loz'=>'9674', 'spades'=>'9824', 'clubs'=>'9827', 'hearts'=>'9829', 'diams'=>'9830', 'apos'=>'39', 'OElig'=>'338', 'oelig'=>'339', 'Scaron'=>'352', 'scaron'=>'353', 'Yuml'=>'376', 'circ'=>'710', 'tilde'=>'732', 'ensp'=>'8194', 'emsp'=>'8195', 'thinsp'=>'8201', 'zwnj'=>'8204', 'zwj'=>'8205', 'lrm'=>'8206', 'rlm'=>'8207', 'ndash'=>'8211', 'mdash'=>'8212', 'lsquo'=>'8216', 'rsquo'=>'8217', 'sbquo'=>'8218', 'ldquo'=>'8220', 'rdquo'=>'8221', 'bdquo'=>'8222', 'dagger'=>'8224', 'Dagger'=>'8225', 'permil'=>'8240', 'lsaquo'=>'8249', 'rsaquo'=>'8250', 'euro'=>'8364', 'nbsp'=>'160', 'iexcl'=>'161', 'cent'=>'162', 'pound'=>'163', 'curren'=>'164', 'yen'=>'165', 'brvbar'=>'166', 'sect'=>'167', 'uml'=>'168', 'copy'=>'169', 'ordf'=>'170', 'laquo'=>'171', 'not'=>'172', 'shy'=>'173', 'reg'=>'174', 'macr'=>'175', 'deg'=>'176', 'plusmn'=>'177', 'sup2'=>'178', 'sup3'=>'179', 'acute'=>'180', 'micro'=>'181', 'para'=>'182', 'middot'=>'183', 'cedil'=>'184', 'sup1'=>'185', 'ordm'=>'186', 'raquo'=>'187', 'frac14'=>'188', 'frac12'=>'189', 'frac34'=>'190', 'iquest'=>'191', 'Agrave'=>'192', 'Aacute'=>'193', 'Acirc'=>'194', 'Atilde'=>'195', 'Auml'=>'196', 'Aring'=>'197', 'AElig'=>'198', 'Ccedil'=>'199', 'Egrave'=>'200', 'Eacute'=>'201', 'Ecirc'=>'202', 'Euml'=>'203', 'Igrave'=>'204', 'Iacute'=>'205', 'Icirc'=>'206', 'Iuml'=>'207', 'ETH'=>'208', 'Ntilde'=>'209', 'Ograve'=>'210', 'Oacute'=>'211', 'Ocirc'=>'212', 'Otilde'=>'213', 'Ouml'=>'214', 'times'=>'215', 'Oslash'=>'216', 'Ugrave'=>'217', 'Uacute'=>'218', 'Ucirc'=>'219', 'Uuml'=>'220', 'Yacute'=>'221', 'THORN'=>'222', 'szlig'=>'223', 'agrave'=>'224', 'aacute'=>'225', 'acirc'=>'226', 'atilde'=>'227', 'auml'=>'228', 'aring'=>'229', 'aelig'=>'230', 'ccedil'=>'231', 'egrave'=>'232', 'eacute'=>'233', 'ecirc'=>'234', 'euml'=>'235', 'igrave'=>'236', 'iacute'=>'237', 'icirc'=>'238', 'iuml'=>'239', 'eth'=>'240', 'ntilde'=>'241', 'ograve'=>'242', 'oacute'=>'243', 'ocirc'=>'244', 'otilde'=>'245', 'ouml'=>'246', 'divide'=>'247', 'oslash'=>'248', 'ugrave'=>'249', 'uacute'=>'250', 'ucirc'=>'251', 'uuml'=>'252', 'yacute'=>'253', 'thorn'=>'254', 'yuml'=>'255'); |
| 318 | if($t[0] != '#'){ |
| 319 | return ($C['and_mark'] ? "\x06" : '&'). (isset($U[$t]) ? $t : (isset($N[$t]) ? (!$C['named_entity'] ? '#'. ($C['hexdec_entity'] > 1 ? 'x'. dechex($N[$t]) : $N[$t]) : $t) : 'amp;'. $t)). ';'; |
| 320 | } |
| 321 | if(($n = ctype_digit($t = substr($t, 1)) ? intval($t) : hexdec(substr($t, 1))) < 9 or ($n > 13 && $n < 32) or $n == 11 or $n == 12 or ($n > 126 && $n < 160 && $n != 133) or ($n > 55295 && ($n < 57344 or ($n > 64975 && $n < 64992) or $n == 65534 or $n == 65535 or $n > 1114111))){ |
| 322 | return ($C['and_mark'] ? "\x06" : '&'). "amp;#{$t};"; |
| 323 | } |
| 324 | return ($C['and_mark'] ? "\x06" : '&'). '#'. (((ctype_digit($t) && $C['hexdec_entity'] < 2) or !$C['hexdec_entity']) ? $n : 'x'. dechex($n)). ';'; |
| 325 | // eof |
| 326 | } |
| 327 | |
| 328 | function hl_prot($p, $c=null){ |
| 329 | // check URL scheme |
| 330 | global $C; |
| 331 | $b = $a = ''; |
| 332 | if($c == null){$c = 'style'; $b = $p[1]; $a = $p[3]; $p = trim($p[2]);} |
| 333 | $c = isset($C['schemes'][$c]) ? $C['schemes'][$c] : $C['schemes']['*']; |
| 334 | if(isset($c['*']) or !strcspn($p, '#?;')){return "{$b}{$p}{$a}";} // All ok, frag, query, param |
| 335 | if(preg_match('`^([a-z\d\-+.&#; ]+?)(:|&#(58|x3a);|%3a|\\\\0{0,4}3a).`i', $p, $m) && !isset($c[strtolower($m[1])])){ // Denied prot |
| 336 | return "{$b}denied:{$p}{$a}"; |
| 337 | } |
| 338 | if($C['abs_url']){ |
| 339 | if($C['abs_url'] == -1 && strpos($p, $C['base_url']) === 0){ // Make url rel |
| 340 | $p = substr($p, strlen($C['base_url'])); |
| 341 | }elseif(empty($m[1])){ // Make URL abs |
| 342 | if(substr($p, 0, 2) == '//'){$p = substr($C['base_url'], 0, strpos($C['base_url'], ':')+1). $p;} |
| 343 | elseif($p[0] == '/'){$p = preg_replace('`(^.+?://[^/]+)(.*)`', '$1', $C['base_url']). $p;} |
| 344 | elseif(strcspn($p, './')){$p = $C['base_url']. $p;} |
| 345 | else{ |
| 346 | preg_match('`^([a-zA-Z\d\-+.]+://[^/]+)(.*)`', $C['base_url'], $m); |
| 347 | $p = preg_replace('`(?<=/)\./`', '', $m[2]. $p); |
| 348 | while(preg_match('`(?<=/)([^/]{3,}|[^/.]+?|\.[^/.]|[^/.]\.)/\.\./`', $p)){ |
| 349 | $p = preg_replace('`(?<=/)([^/]{3,}|[^/.]+?|\.[^/.]|[^/.]\.)/\.\./`', '', $p); |
| 350 | } |
| 351 | $p = $m[1]. $p; |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | return "{$b}{$p}{$a}"; |
| 356 | // eof |
| 357 | } |
| 358 | |
| 359 | function hl_regex($p){ |
| 360 | // ?ok regex |
| 361 | if(empty($p)){return 0;} |
| 362 | if($t = ini_get('track_errors')){$o = isset($php_errormsg) ? $php_errormsg : null;} |
| 363 | else{ini_set('track_errors', 1);} |
| 364 | unset($php_errormsg); |
| 365 | if(($d = ini_get('display_errors'))){ini_set('display_errors', 0);} |
| 366 | preg_match($p, ''); |
| 367 | if($d){ini_set('display_errors', 1);} |
| 368 | $r = isset($php_errormsg) ? 0 : 1; |
| 369 | if($t){$php_errormsg = isset($o) ? $o : null;} |
| 370 | else{ini_set('track_errors', 0);} |
| 371 | return $r; |
| 372 | // eof |
| 373 | } |
| 374 | |
| 375 | function hl_spec($t){ |
| 376 | // finalize $spec |
| 377 | $s = array(); |
| 378 | $t = str_replace(array("\t", "\r", "\n", ' '), '', preg_replace('/"(?>(`.|[^"])*)"/sme', 'substr(str_replace(array(";", "|", "~", " ", ",", "/", "(", ")", \'`"\'), array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\""), "$0"), 1, -1)', trim($t))); |
| 379 | for($i = count(($t = explode(';', $t))); --$i>=0;){ |
| 380 | $w = $t[$i]; |
| 381 | if(empty($w) or ($e = strpos($w, '=')) === false or !strlen(($a = substr($w, $e+1)))){continue;} |
| 382 | $y = $n = array(); |
| 383 | foreach(explode(',', $a) as $v){ |
| 384 | if(!preg_match('`^([a-z:\-\*]+)(?:\((.*?)\))?`i', $v, $m)){continue;} |
| 385 | if(($x = strtolower($m[1])) == '-*'){$n['*'] = 1; continue;} |
| 386 | if($x[0] == '-'){$n[substr($x, 1)] = 1; continue;} |
| 387 | if(!isset($m[2])){$y[$x] = 1; continue;} |
| 388 | foreach(explode('/', $m[2]) as $m){ |
| 389 | if(empty($m) or ($p = strpos($m, '=')) == 0 or $p < 5){$y[$x] = 1; continue;} |
| 390 | $y[$x][strtolower(substr($m, 0, $p))] = str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08"), array(";", "|", "~", " ", ",", "/", "(", ")"), substr($m, $p+1)); |
| 391 | } |
| 392 | if(isset($y[$x]['match']) && !hl_regex($y[$x]['match'])){unset($y[$x]['match']);} |
| 393 | if(isset($y[$x]['nomatch']) && !hl_regex($y[$x]['nomatch'])){unset($y[$x]['nomatch']);} |
| 394 | } |
| 395 | if(!count($y) && !count($n)){continue;} |
| 396 | if(!isset($n['*'])){ |
| 397 | foreach($y as $k=>$v){ |
| 398 | if(!is_array($v) or !count($v)){unset($y[$k]);} |
| 399 | } |
| 400 | } |
| 401 | foreach(explode(',', substr($w, 0, $e)) as $v){ |
| 402 | if(!strlen(($v = strtolower($v)))){continue;} |
| 403 | if(count($y)){$s[$v] = $y;} |
| 404 | if(count($n)){$s[$v]['n'] = $n;} |
| 405 | } |
| 406 | } |
| 407 | return $s; |
| 408 | // eof |
| 409 | } |
| 410 | |
| 411 | function hl_tag($t){ |
| 412 | // tag/attribute handler |
| 413 | global $C; |
| 414 | $t = $t[0]; |
| 415 | // invalid < > |
| 416 | if($t == '< '){return '< ';} |
| 417 | if($t == '>'){return '>';} |
| 418 | if(!preg_match('`^<(/?)([a-zA-Z][a-zA-Z1-6]*)([^>]*?)\s?>$`m', $t, $m)){ |
| 419 | return str_replace(array('<', '>'), array('<', '>'), $t); |
| 420 | }elseif(!isset($C['elements'][($e = strtolower($m[2]))])){ |
| 421 | return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('<', '>'), $t) : ''); |
| 422 | } |
| 423 | // attr string |
| 424 | $a = str_replace(array("\xad", "\n", "\r", "\t"), ' ', trim($m[3])); |
| 425 | if(strpos($a, '&') !== false){ |
| 426 | str_replace(array('­', '­', '­'), ' ', $a); |
| 427 | } |
| 428 | // tag transform |
| 429 | static $eD = array('applet'=>1, 'center'=>1, 'dir'=>1, 'embed'=>1, 'font'=>1, 'isindex'=>1, 'menu'=>1, 's'=>1, 'strike'=>1, 'u'=>1); // Deprecated |
| 430 | if($C['make_tag_strict'] && isset($eD[$e])){ |
| 431 | $trt = hl_tag2($e, $a, $C['make_tag_strict']); |
| 432 | if(!$e){return (($C['keep_bad']%2) ? str_replace(array('<', '>'), array('<', '>'), $t) : '');} |
| 433 | } |
| 434 | // close tag |
| 435 | static $eE = array('area'=>1, 'br'=>1, 'col'=>1, 'embed'=>1, 'hr'=>1, 'img'=>1, 'input'=>1, 'isindex'=>1, 'param'=>1); // Empty ele |
| 436 | if(!empty($m[1])){ |
| 437 | return (!isset($eE[$e]) ? "</$e>" : (($C['keep_bad'])%2 ? str_replace(array('<', '>'), array('<', '>'), $t) : '')); |
| 438 | } |
| 439 | |
| 440 | // open tag & attr |
| 441 | static $aN = array('abbr'=>array('td'=>1, 'th'=>1), 'accept-charset'=>array('form'=>1), 'accept'=>array('form'=>1, 'input'=>1), 'accesskey'=>array('a'=>1, 'area'=>1, 'button'=>1, 'input'=>1, 'label'=>1, 'legend'=>1, 'textarea'=>1), 'action'=>array('form'=>1), 'align'=>array('caption'=>1, 'embed'=>1, 'applet'=>1, 'iframe'=>1, 'img'=>1, 'input'=>1, 'object'=>1, 'legend'=>1, 'table'=>1, 'hr'=>1, 'div'=>1, 'h1'=>1, 'h2'=>1, 'h3'=>1, 'h4'=>1, 'h5'=>1, 'h6'=>1, 'p'=>1, 'col'=>1, 'colgroup'=>1, 'tbody'=>1, 'td'=>1, 'tfoot'=>1, 'th'=>1, 'thead'=>1, 'tr'=>1), 'alt'=>array('applet'=>1, 'area'=>1, 'img'=>1, 'input'=>1), 'archive'=>array('applet'=>1, 'object'=>1), 'axis'=>array('td'=>1, 'th'=>1), 'bgcolor'=>array('embed'=>1, 'table'=>1, 'tr'=>1, 'td'=>1, 'th'=>1), 'border'=>array('table'=>1, 'img'=>1, 'object'=>1), 'bordercolor'=>array('table'=>1, 'td'=>1, 'tr'=>1), 'cellpadding'=>array('table'=>1), 'cellspacing'=>array('table'=>1), 'char'=>array('col'=>1, 'colgroup'=>1, 'tbody'=>1, 'td'=>1, 'tfoot'=>1, 'th'=>1, 'thead'=>1, 'tr'=>1), 'charoff'=>array('col'=>1, 'colgroup'=>1, 'tbody'=>1, 'td'=>1, 'tfoot'=>1, 'th'=>1, 'thead'=>1, 'tr'=>1), 'charset'=>array('a'=>1, 'script'=>1), 'checked'=>array('input'=>1), 'cite'=>array('blockquote'=>1, 'q'=>1, 'del'=>1, 'ins'=>1), 'classid'=>array('object'=>1), 'clear'=>array('br'=>1), 'code'=>array('applet'=>1), 'codebase'=>array('object'=>1, 'applet'=>1), 'codetype'=>array('object'=>1), 'color'=>array('font'=>1), 'cols'=>array('textarea'=>1), 'colspan'=>array('td'=>1, 'th'=>1), 'compact'=>array('dir'=>1, 'dl'=>1, 'menu'=>1, 'ol'=>1, 'ul'=>1), 'coords'=>array('area'=>1, 'a'=>1), 'data'=>array('object'=>1), 'datetime'=>array('del'=>1, 'ins'=>1), 'declare'=>array('object'=>1), 'defer'=>array('script'=>1), 'dir'=>array('bdo'=>1), 'disabled'=>array('button'=>1, 'input'=>1, 'optgroup'=>1, 'option'=>1, 'select'=>1, 'textarea'=>1), 'enctype'=>array('form'=>1), 'face'=>array('font'=>1), 'for'=>array('label'=>1), 'frame'=>array('table'=>1), 'frameborder'=>array('iframe'=>1), 'headers'=>array('td'=>1, 'th'=>1), 'height'=>array('embed'=>1, 'iframe'=>1, 'td'=>1, 'th'=>1, 'img'=>1, 'object'=>1, 'applet'=>1), 'href'=>array('a'=>1, 'area'=>1), 'hreflang'=>array('a'=>1), 'hspace'=>array('applet'=>1, 'img'=>1, 'object'=>1), 'ismap'=>array('img'=>1, 'input'=>1), 'label'=>array('option'=>1, 'optgroup'=>1), 'language'=>array('script'=>1), 'longdesc'=>array('img'=>1, 'iframe'=>1), 'marginheight'=>array('iframe'=>1), 'marginwidth'=>array('iframe'=>1), 'maxlength'=>array('input'=>1), 'method'=>array('form'=>1), 'model'=>array('embed'=>1), 'multiple'=>array('select'=>1), 'name'=>array('button'=>1, 'embed'=>1, 'textarea'=>1, 'applet'=>1, 'select'=>1, 'form'=>1, 'iframe'=>1, 'img'=>1, 'a'=>1, 'input'=>1, 'object'=>1, 'map'=>1, 'param'=>1), 'nohref'=>array('area'=>1), 'noshade'=>array('hr'=>1), 'nowrap'=>array('td'=>1, 'th'=>1), 'object'=>array('applet'=>1), 'onblur'=>array('a'=>1, 'area'=>1, 'button'=>1, 'input'=>1, 'label'=>1, 'select'=>1, 'textarea'=>1), 'onchange'=>array('input'=>1, 'select'=>1, 'textarea'=>1), 'onfocus'=>array('a'=>1, 'area'=>1, 'button'=>1, 'input'=>1, 'label'=>1, 'select'=>1, 'textarea'=>1), 'onreset'=>array('form'=>1), 'onselect'=>array('input'=>1, 'textarea'=>1), 'onsubmit'=>array('form'=>1), 'pluginspage'=>array('embed'=>1), 'pluginurl'=>array('embed'=>1), 'prompt'=>array('isindex'=>1), 'readonly'=>array('textarea'=>1, 'input'=>1), 'rel'=>array('a'=>1), 'rev'=>array('a'=>1), 'rows'=>array('textarea'=>1), 'rowspan'=>array('td'=>1, 'th'=>1), 'rules'=>array('table'=>1), 'scope'=>array('td'=>1, 'th'=>1), 'scrolling'=>array('iframe'=>1), 'selected'=>array('option'=>1), 'shape'=>array('area'=>1, 'a'=>1), 'size'=>array('hr'=>1, 'font'=>1, 'input'=>1, 'select' |