From 14138dd097ccb6bd4b96c0239075df811be67b80 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Tue, 23 Feb 2021 23:09:31 +0300 Subject: [PATCH] show line number and code in the errorreporting rule --- .../libraries/rules/errorreporting.php | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/administrator/components/com_jedchecker/libraries/rules/errorreporting.php b/administrator/components/com_jedchecker/libraries/rules/errorreporting.php index f74f669..d4e3f21 100644 --- a/administrator/components/com_jedchecker/libraries/rules/errorreporting.php +++ b/administrator/components/com_jedchecker/libraries/rules/errorreporting.php @@ -63,8 +63,7 @@ class JedcheckerRulesErrorreporting extends JEDcheckerRule // Try to find the base64 use in the file if ($this->find($file)) { - // Add as error to the report if it was not found - $this->report->addError($file, JText::_('COM_JEDCHECKER_ERROR_ERRORREPORTING')); + // The error has been added by the find() method } } } @@ -84,22 +83,28 @@ class JedcheckerRulesErrorreporting extends JEDcheckerRule // Get the functions to look for $encodings = explode(',', $this->params->get('errorreportings')); - foreach ($encodings as $encoding) + foreach ($encodings as $i => $encoding) { - $encoding = trim($encoding); + $encodings[$i] = trim($encoding); + } - foreach ($content AS $line) + $found = false; + + foreach ($content as $i => $line) + { + foreach ($encodings as $encoding) { - // Search for "base64" $pos_1 = stripos($line, $encoding); if ($pos_1 !== false) { - return true; + $found = true; + $this->report->addError($file, JText::_('COM_JEDCHECKER_ERROR_ERRORREPORTING'), $i + 1, $line); + break; } } } - return false; + return $found; } }