mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-02-24 23:08:08 +08:00
Attempt to <a> bugs in HTML emails #187
This commit is contained in:
parent
ca14fd3423
commit
4fa37ce187
1 changed files with 21 additions and 14 deletions
|
@ -45,9 +45,29 @@ abstract class HtmlUtils
|
|||
$bState = \libxml_use_internal_errors(true);
|
||||
}
|
||||
|
||||
$sText = \str_replace('<o:p></o:p>', '', $sText);
|
||||
$sText = \str_replace('<o:p>', '<span>', $sText);
|
||||
$sText = \str_replace('</o:p>', '</span>', $sText);
|
||||
// $sText = \preg_replace('#<!--.*?-->#s', '', $sText);
|
||||
|
||||
// https://github.com/the-djmaze/snappymail/issues/187
|
||||
$sText = \preg_replace('#<a[^>]*>(((?!</a).)+<a\\s)#si', '$1', $sText);
|
||||
|
||||
if (\function_exists('tidy_repair_string')) {
|
||||
# http://tidy.sourceforge.net/docs/quickref.html
|
||||
$tidyConfig = array(
|
||||
'bare' => 1,
|
||||
'join-classes' => 1,
|
||||
'newline' => 'LF',
|
||||
'numeric-entities' => 1,
|
||||
'quote-nbsp' => 0,
|
||||
'word-2000' => 1
|
||||
);
|
||||
$sText = \tidy_repair_string($sText, $tidyConfig, 'utf8');
|
||||
}
|
||||
|
||||
$sHtmlAttrs = $sBodyAttrs = '';
|
||||
|
||||
$sText = static::FixSchemas($sText);
|
||||
$sText = static::ClearFastTags($sText);
|
||||
$sText = static::ClearBodyAndHtmlTag($sText, $sHtmlAttrs, $sBodyAttrs);
|
||||
|
||||
|
@ -178,19 +198,6 @@ abstract class HtmlUtils
|
|||
return $sHtml;
|
||||
}
|
||||
|
||||
private static function FixSchemas(string $sHtml, bool $bClearEmpty = true) : string
|
||||
{
|
||||
if ($bClearEmpty)
|
||||
{
|
||||
$sHtml = \str_replace('<o:p></o:p>', '', $sHtml);
|
||||
}
|
||||
|
||||
$sHtml = \str_replace('<o:p>', '<span>', $sHtml);
|
||||
$sHtml = \str_replace('</o:p>', '</span>', $sHtml);
|
||||
|
||||
return $sHtml;
|
||||
}
|
||||
|
||||
private static function ClearFastTags(string $sHtml) : string
|
||||
{
|
||||
return \preg_replace(array(
|
||||
|
|
Loading…
Reference in a new issue