X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fhtmlawed%2FhtmLawed%2FhtmLawed.php;fp=web%2Fmodules%2Fcontrib%2Fhtmlawed%2FhtmLawed%2FhtmLawed.php;h=7b05dd871bbcea785fc9f3d4d55eca6c2a7e6364;hp=5bb5d7ee8876b693e25b2d94b5308a6629a28a71;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/modules/contrib/htmlawed/htmLawed/htmLawed.php b/web/modules/contrib/htmlawed/htmLawed/htmLawed.php index 5bb5d7ee8..7b05dd871 100755 --- a/web/modules/contrib/htmlawed/htmLawed/htmLawed.php +++ b/web/modules/contrib/htmlawed/htmLawed/htmLawed.php @@ -1,7 +1,7 @@ (`.|[^"])*)"/sm', create_function('$m', 'return substr(str_replace(array(";", "|", "~", " ", ",", "/", "(", ")", \'`"\'), array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\""), $m[0]), 1, -1);'), trim($t))); +if(!function_exists('hl_aux1')){function hl_aux1($m){ + return substr(str_replace(array(";", "|", "~", " ", ",", "/", "(", ")", '`"'), array("\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", '"'), $m[0]), 1, -1); +}} +$t = str_replace(array("\t", "\r", "\n", ' '), '', preg_replace_callback('/"(?>(`.|[^"])*)"/sm', 'hl_aux1', trim($t))); for($i = count(($t = explode(';', $t))); --$i>=0;){ $w = $t[$i]; if(empty($w) or ($e = strpos($w, '=')) === false or !strlen(($a = substr($w, $e+1)))){continue;} $y = $n = array(); foreach(explode(',', $a) as $v){ - if(!preg_match('`^([a-z][^=/()]+)(?:\((.*?)\))?`i', $v, $m)){continue;} + if(!preg_match('`^([a-z:\-\*]+)(?:\((.*?)\))?`i', $v, $m)){continue;} if(($x = strtolower($m[1])) == '-*'){$n['*'] = 1; continue;} if($x[0] == '-'){$n[substr($x, 1)] = 1; continue;} if(!isset($m[2])){$y[$x] = 1; continue;} @@ -401,8 +410,8 @@ for($i = count(($t = explode(';', $t))); --$i>=0;){ if(!count($y) && !count($n)){continue;} foreach(explode(',', substr($w, 0, $e)) as $v){ if(!strlen(($v = strtolower($v)))){continue;} - if(count($y)){$s[$v] = $y;} - if(count($n)){$s[$v]['n'] = $n;} + if(count($y)){if(!isset($s[$v])){$s[$v] = $y;} else{$s[$v] = array_merge($s[$v], $y);}} + if(count($n)){if(!isset($s[$v]['n'])){$s[$v]['n'] = $n;} else{$s[$v]['n'] = array_merge($s[$v]['n'], $n);}} } } return $s; @@ -562,6 +571,7 @@ if($depTr){ $c = array(); foreach($a as $k=>$v){ if($k == 'style' or !isset($aND[$k][$e])){continue;} + $v = str_replace(array('\\', ':', ';', '&#'), '', $v); if($k == 'align'){ unset($a['align']); if($e == 'img' && ($v == 'left' or $v == 'right')){$c[] = 'float: '. $v;} @@ -659,7 +669,10 @@ return ''; function hl_tidy($t, $w, $p){ // tidy/compact HTM if(strpos(' pre,script,textarea', "$p,")){return $t;} -$t = preg_replace(array('`(<\w[^>]*(?)\s+`', '`\s+`', '`(<\w[^>]*(?) `'), array(' $1', ' ', '$1'), preg_replace_callback(array('`(<(!\[CDATA\[))(.+?)(\]\]>)`sm', '`(<(!--))(.+?)(-->)`sm', '`(<(pre|script|textarea)[^>]*?>)(.+?)()`sm'), create_function('$m', 'return $m[1]. str_replace(array("<", ">", "\n", "\r", "\t", " "), array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), $m[3]). $m[4];'), $t)); +if(!function_exists('hl_aux2')){function hl_aux2($m){ + return $m[1]. str_replace(array("<", ">", "\n", "\r", "\t", ' '), array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), $m[3]). $m[4]; +}} +$t = preg_replace(array('`(<\w[^>]*(?)\s+`', '`\s+`', '`(<\w[^>]*(?) `'), array(' $1', ' ', '$1'), preg_replace_callback(array('`(<(!\[CDATA\[))(.+?)(\]\]>)`sm', '`(<(!--))(.+?)(-->)`sm', '`(<(pre|script|textarea)[^>]*?>)(.+?)()`sm'), 'hl_aux2', $t)); if(($w = strtolower($w)) == -1){ return str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), array('<', '>', "\n", "\r", "\t", ' '), $t); } @@ -712,5 +725,5 @@ return str_replace(array("\x01", "\x02", "\x03", "\x04", "\x05", "\x07"), array( function hl_version(){ // version -return '1.2'; +return '1.2.4.1'; }