From: x2003bruneau Date: Fri, 2 Feb 2007 21:23:18 +0000 (+0000) Subject: Fix HMTL attribute value catcher X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=ff518666cf0f6315560d118caec19bdb7cd145d9;p=banana.git Fix HMTL attribute value catcher git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@193 9869982d-c50d-0410-be91-f2a2ec7c7c7b --- diff --git a/banana/message.func.inc.php b/banana/message.func.inc.php index e50023e..be686ec 100644 --- a/banana/message.func.inc.php +++ b/banana/message.func.inc.php @@ -284,10 +284,10 @@ function banana_cleanStyles($tag, $attributes) $attributes = str_replace("\n", ' ', stripslashes($attributes)); $attributes = str_replace('= "', '="', $attributes); foreach ($conv as $att=>$stl) { - $pattern = '/\b' . preg_quote($att, '/') . '="(.+?)"/i'; + $pattern = '/\b' . preg_quote($att, '/') . '=([\'"])?(.+?)(?(1)\1|(?:$| ))/i'; if (preg_match($pattern, $attributes, $matches)) { $attributes = preg_replace($pattern, '', $attributes); - $val = $matches[1]; + $val = $matches[2]; if ($att == 'cellspacing' && strpos($style, 'border-collapse') === false) { $style .= "border-collapse: separate; border-spacing: $val $val; "; } elseif ($att == 'cellpadding' && $tag == 'table') { @@ -381,7 +381,7 @@ function banana_cleanHtml($source, $to_xhtml = false) // Use inlined style instead of old html attributes if ($to_xhtml) { - $source = preg_replace('/<(\/?\w+)(.*?)(\/?>)/ise', "'<\\1' . banana_cleanStyles('\\1', '\\2') . '\\3'", $source); + $source = preg_replace('/<(\/?\w+)(.*?)(\/?>)/uise', "'<\\1' . banana_cleanStyles('\\1', '\\2') . '\\3'", $source); } return preg_replace('/<(.*?)>/ie', "'<'.banana_removeEvilAttributes('\\1').'>'", $source); }