31
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-09-27 20:49:05 +00:00

fix processing of one-line comments

This commit is contained in:
Denis Ryabov 2021-05-21 21:26:02 +03:00
parent d1a1bfd10b
commit cbd3bd8f9e

View File

@ -169,7 +169,7 @@ abstract class JEDCheckerHelper
$code = substr($content, 0, $pos);
$cleanContent = $isCleanHtml ? self::removeContent($code) : $code;
while (preg_match('/(?:[\'"]|\/\*|\/\/|\?>)/', $content, $match, PREG_OFFSET_CAPTURE, $pos))
while (preg_match('/(?:[\'"]|\/\*|\/\/|#|\?>)/', $content, $match, PREG_OFFSET_CAPTURE, $pos))
{
$foundPos = $match[0][1];
$cleanContent .= substr($content, $pos, $foundPos - $pos);
@ -210,7 +210,14 @@ abstract class JEDCheckerHelper
break;
case '//':
case '#':
$commentLen = strcspn($content, "\r\n", $pos);
$endPhpPos = strpos($content, '?>', $pos);
if ($endPhpPos !== false && $endPhpPos < $pos + $commentLen)
{
$commentLen = $endPhpPos - $pos;
}
if (!$isCleanComments)
{
@ -218,6 +225,7 @@ abstract class JEDCheckerHelper
}
$pos += $commentLen;
break;
case '?>':