mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-08 08:57:03 +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];
|
$sBodyAttrs = $aMatch[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
$sHtml = \preg_replace('/^.*<body([^>]*)>/sim', '', $sHtml);
|
$sHtml = \preg_replace('/^.*<body([^>]*)>/si', '', $sHtml);
|
||||||
$sHtml = \preg_replace('/<\/body>/im', '', $sHtml);
|
$sHtml = \preg_replace('/<\/body>/i', '', $sHtml);
|
||||||
$sHtml = \preg_replace('/<html([^>]*)>/im', '', $sHtml);
|
$sHtml = \preg_replace('/<html([^>]*)>/i', '', $sHtml);
|
||||||
$sHtml = \preg_replace('/<\/html>/im', '', $sHtml);
|
$sHtml = \preg_replace('/<\/html>/i', '', $sHtml);
|
||||||
|
|
||||||
$sHtmlAttrs = \preg_replace('/xmlns:[a-z]="[^"]*"/im', '', $sHtmlAttrs);
|
$sHtmlAttrs = \preg_replace('/xmlns:[a-z]="[^"]*"/i', '', $sHtmlAttrs);
|
||||||
$sHtmlAttrs = \preg_replace('/xmlns="[^"]*"/im', '', $sHtmlAttrs);
|
$sHtmlAttrs = \preg_replace('/xmlns="[^"]*"/i', '', $sHtmlAttrs);
|
||||||
$sBodyAttrs = \preg_replace('/xmlns:[a-z]="[^"]*"/im', '', $sBodyAttrs);
|
$sBodyAttrs = \preg_replace('/xmlns:[a-z]="[^"]*"/i', '', $sBodyAttrs);
|
||||||
|
|
||||||
return $sHtml;
|
return $sHtml;
|
||||||
}
|
}
|
||||||
|
|
@ -229,8 +229,8 @@ class HtmlUtils
|
||||||
{
|
{
|
||||||
return \preg_replace(array(
|
return \preg_replace(array(
|
||||||
'/<p[^>]*><\/p>/i',
|
'/<p[^>]*><\/p>/i',
|
||||||
'/<!doctype[^>]*>/msi',
|
'/<!doctype[^>]*>/i',
|
||||||
'/<\?xml [^>]*\?>/msi'
|
'/<\?xml [^>]*\?>/i'
|
||||||
), '', $sHtml);
|
), '', $sHtml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -827,8 +827,11 @@ class HtmlUtils
|
||||||
$oDom = \MailSo\Base\HtmlUtils::GetDomFromText($sHtml);
|
$oDom = \MailSo\Base\HtmlUtils::GetDomFromText($sHtml);
|
||||||
unset($sHtml);
|
unset($sHtml);
|
||||||
|
|
||||||
if ($oDom)
|
if (!$oDom)
|
||||||
{
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
if ($fAdditionalDomReader)
|
if ($fAdditionalDomReader)
|
||||||
{
|
{
|
||||||
$oResDom = \call_user_func($fAdditionalDomReader, $oDom);
|
$oResDom = \call_user_func($fAdditionalDomReader, $oDom);
|
||||||
|
|
@ -1119,8 +1122,6 @@ class HtmlUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
$sResult = \MailSo\Base\HtmlUtils::GetTextFromDom($oDom, $bWrapByFakeHtmlAndBodyDiv);
|
$sResult = \MailSo\Base\HtmlUtils::GetTextFromDom($oDom, $bWrapByFakeHtmlAndBodyDiv);
|
||||||
}
|
|
||||||
|
|
||||||
unset($oDom);
|
unset($oDom);
|
||||||
|
|
||||||
return $sResult;
|
return $sResult;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue