Optimize HTML parsing (#1075)

This commit is contained in:
RainLoop Team 2016-06-18 22:09:31 +03:00
parent f6c78ee1fa
commit 9a1d5dd1d3

View file

@ -236,7 +236,18 @@ class HtmlUtils
$sBodyAttrs = $aMatch[1];
}
$sHtml = \preg_replace('/^.*<body([^>]*)>/si', '', $sHtml);
$iPos = \stripos($sHtml, '<body>');
if (0 < $iPos)
{
$sHtml = \substr($sHtml, $iPos);
}
else
{
$iPos = \stripos($sHtml, '<body ');
$sHtml = 0 < $iPos ? \substr($sHtml, $iPos) : $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);