when converting HTML 2 Text remove style,head and comment style browser-switch

This commit is contained in:
Klaus Leithoff 2012-06-04 14:54:08 +00:00
parent 30f8a711e3
commit 8abb10c5ed
2 changed files with 14 additions and 1 deletions

View File

@ -4381,6 +4381,16 @@ class felamimail_bo
{
$newBody = $cleaned;
}
if (!$preserveHTML)
{
// filter only the 'body', as we only want that part, if we throw away the html
preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches);
if ($matches[2])
{
$hasOther = true;
$newBody = $matches[2];
}
}
}
else
{

View File

@ -1196,7 +1196,10 @@ class translation
#print "<pre>"; print htmlspecialchars($_html);
#print "</pre>";
#print "<hr>";
self::replaceTagsCompletley($_html,'style');
if (stripos($_html,'style')!==false) self::replaceTagsCompletley($_html,'style'); // clean out empty or pagewide style definitions / left over tags
if (stripos($_html,'head')!==false) self::replaceTagsCompletley($_html,'head'); // Strip out stuff in head
if (stripos($_html,'![if')!==false && stripos($_html,'<![endif]>')!==false) self::replaceTagsCompletley($_html,'!\[if','<!\[endif\]>',false); // Strip out stuff in ifs
if (stripos($_html,'!--[if')!==false && stripos($_html,'<![endif]-->')!==false) self::replaceTagsCompletley($_html,'!--\[if','<!\[endif\]-->',false); // Strip out stuff in ifs
$Rules = array ('@<script[^>]*?>.*?</script>@siU', // Strip out javascript
'@&(quot|#34);@i', // Replace HTML entities
'@&(amp|#38);@i', // Ampersand &