From a243f9b665468ba0b67fb0776f5c1657e14ab36e Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 3 Aug 2022 16:26:38 +0300 Subject: [PATCH 1/4] fix processing of escaped characters in backtick operator --- administrator/components/com_jedchecker/libraries/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_jedchecker/libraries/helper.php b/administrator/components/com_jedchecker/libraries/helper.php index d3a95ed..a07bd45 100644 --- a/administrator/components/com_jedchecker/libraries/helper.php +++ b/administrator/components/com_jedchecker/libraries/helper.php @@ -192,7 +192,7 @@ abstract class JEDCheckerHelper break; case '`': - if (!preg_match("/`.*?`/As", $content, $match, 0, $pos)) + if (!preg_match("/`(?>[^`\\\\]+|\\\\.)*`/As", $content, $match, 0, $pos)) { return $cleanContent . substr($content, $pos); } From 227b182bd7247ba09da454449c52c14cdef4bcee Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 3 Aug 2022 16:26:57 +0300 Subject: [PATCH 2/4] fix processing of escaped characters in strings --- administrator/components/com_jedchecker/libraries/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_jedchecker/libraries/helper.php b/administrator/components/com_jedchecker/libraries/helper.php index a07bd45..b6ad54e 100644 --- a/administrator/components/com_jedchecker/libraries/helper.php +++ b/administrator/components/com_jedchecker/libraries/helper.php @@ -309,7 +309,7 @@ abstract class JEDCheckerHelper $pos = 0; $cleanContent = ''; - while (preg_match('/\n|\\|\{\$|\$\{/', $content, $match, PREG_OFFSET_CAPTURE, $pos)) + while (preg_match('/\n|\\\\|\{\$|\$\{/', $content, $match, PREG_OFFSET_CAPTURE, $pos)) { $foundPos = $match[0][1]; $cleanContent .= substr($content, $pos, $foundPos - $pos); From 7ae3b1d3991f2c605f4f5742e28780e218689250 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 3 Aug 2022 16:27:21 +0300 Subject: [PATCH 3/4] fix cleaning of string content --- .../com_jedchecker/libraries/helper.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/helper.php b/administrator/components/com_jedchecker/libraries/helper.php index b6ad54e..3a61ef5 100644 --- a/administrator/components/com_jedchecker/libraries/helper.php +++ b/administrator/components/com_jedchecker/libraries/helper.php @@ -303,7 +303,7 @@ abstract class JEDCheckerHelper { if (!$parse) { - return str_repeat("\n", substr_count($content, "\n")); + return self::cleanLines($content); } $pos = 0; @@ -312,7 +312,7 @@ abstract class JEDCheckerHelper while (preg_match('/\n|\\\\|\{\$|\$\{/', $content, $match, PREG_OFFSET_CAPTURE, $pos)) { $foundPos = $match[0][1]; - $cleanContent .= substr($content, $pos, $foundPos - $pos); + $cleanContent .= self::cleanLines(substr($content, $pos, $foundPos - $pos)); $pos = $foundPos; switch ($match[0][0]) @@ -384,4 +384,17 @@ abstract class JEDCheckerHelper return $cleanContent; } + + /** + * Remove all content except of EOLs to preserve line numbers + * + * @param string $content + * + * @return string + * @since 2.4.2 + */ + protected static function cleanLines($content) + { + return str_repeat("\n", substr_count($content, "\n")); + } } From 86a35d2c7f52eb0c52340ea9a67a282bf1ef1bcf Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Wed, 3 Aug 2022 16:27:31 +0300 Subject: [PATCH 4/4] update copyright --- administrator/components/com_jedchecker/libraries/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/components/com_jedchecker/libraries/helper.php b/administrator/components/com_jedchecker/libraries/helper.php index 3a61ef5..b4a50f1 100644 --- a/administrator/components/com_jedchecker/libraries/helper.php +++ b/administrator/components/com_jedchecker/libraries/helper.php @@ -2,7 +2,7 @@ /** * @package Joomla.JEDChecker * - * @copyright Copyright (C) 2021 Open Source Matters, Inc. All rights reserved. + * @copyright Copyright (C) 2021-2022 Open Source Matters, Inc. All rights reserved. * * @license GNU General Public License version 2 or later; see LICENSE.txt */