mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 10:09:20 +03:00
Optimize parse regex
This commit is contained in:
parent
08ccf55577
commit
c2ab03f69c
1 changed files with 262 additions and 261 deletions
|
|
@ -189,14 +189,14 @@ class HtmlUtils
|
|||
$sBodyAttrs = $aMatch[1];
|
||||
}
|
||||
|
||||
$sHtml = \preg_replace('/^.*<body([^>]*)>/sim', '', $sHtml);
|
||||
$sHtml = \preg_replace('/<\/body>/im', '', $sHtml);
|
||||
$sHtml = \preg_replace('/<html([^>]*)>/im', '', $sHtml);
|
||||
$sHtml = \preg_replace('/<\/html>/im', '', $sHtml);
|
||||
$sHtml = \preg_replace('/^.*<body([^>]*)>/si', '', $sHtml);
|
||||
$sHtml = \preg_replace('/<\/body>/i', '', $sHtml);
|
||||
$sHtml = \preg_replace('/<html([^>]*)>/i', '', $sHtml);
|
||||
$sHtml = \preg_replace('/<\/html>/i', '', $sHtml);
|
||||
|
||||
$sHtmlAttrs = \preg_replace('/xmlns:[a-z]="[^"]*"/im', '', $sHtmlAttrs);
|
||||
$sHtmlAttrs = \preg_replace('/xmlns="[^"]*"/im', '', $sHtmlAttrs);
|
||||
$sBodyAttrs = \preg_replace('/xmlns:[a-z]="[^"]*"/im', '', $sBodyAttrs);
|
||||
$sHtmlAttrs = \preg_replace('/xmlns:[a-z]="[^"]*"/i', '', $sHtmlAttrs);
|
||||
$sHtmlAttrs = \preg_replace('/xmlns="[^"]*"/i', '', $sHtmlAttrs);
|
||||
$sBodyAttrs = \preg_replace('/xmlns:[a-z]="[^"]*"/i', '', $sBodyAttrs);
|
||||
|
||||
return $sHtml;
|
||||
}
|
||||
|
|
@ -229,8 +229,8 @@ class HtmlUtils
|
|||
{
|
||||
return \preg_replace(array(
|
||||
'/<p[^>]*><\/p>/i',
|
||||
'/<!doctype[^>]*>/msi',
|
||||
'/<\?xml [^>]*\?>/msi'
|
||||
'/<!doctype[^>]*>/i',
|
||||
'/<\?xml [^>]*\?>/i'
|
||||
), '', $sHtml);
|
||||
}
|
||||
|
||||
|
|
@ -827,8 +827,11 @@ class HtmlUtils
|
|||
$oDom = \MailSo\Base\HtmlUtils::GetDomFromText($sHtml);
|
||||
unset($sHtml);
|
||||
|
||||
if ($oDom)
|
||||
if (!$oDom)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($fAdditionalDomReader)
|
||||
{
|
||||
$oResDom = \call_user_func($fAdditionalDomReader, $oDom);
|
||||
|
|
@ -1119,8 +1122,6 @@ class HtmlUtils
|
|||
}
|
||||
|
||||
$sResult = \MailSo\Base\HtmlUtils::GetTextFromDom($oDom, $bWrapByFakeHtmlAndBodyDiv);
|
||||
}
|
||||
|
||||
unset($oDom);
|
||||
|
||||
return $sResult;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue