33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-12-29 04:42:36 +00:00

Report spaces/tabs/EOLs at the beginning of PHP file (see issue #164)

This commit is contained in:
Denis Ryabov 2021-11-16 20:16:50 +03:00
parent fa3ba35933
commit 8542f690bd
2 changed files with 8 additions and 0 deletions

View File

@ -83,6 +83,7 @@ COM_JEDCHECKER_ERROR_FRAMEWORK_TODO="TODO statement detected"
COM_JEDCHECKER_ERROR_FRAMEWORK_LEFTOVER_FOLDER="Leftover folder detected"
COM_JEDCHECKER_ERROR_FRAMEWORK_LEFTOVER_FILE="Leftover file detected"
COM_JEDCHECKER_ERROR_FRAMEWORK_STRICT="PHP Strict Standards: Only variables should be assigned by reference"
COM_JEDCHECKER_ERROR_FRAMEWORK_LEADING_SPACES="Spaces at the beginning of PHP file detected (it might result in the 'Cannot modify header information - headers already sent' warning message)"
COM_JEDCHECKER_RULE_JAMSS="JAMSS - Joomla! Anti-Malware Scan Script"
COM_JEDCHECKER_RULE_JAMSS_DESC="JAMSS will raise many flags for use of potentially dangerous methods, additionally checking for some known attack signatures. Find out more on the <a href='https://github.com/btoplak/Joomla-Anti-Malware-Scan-Script' target='_blank'>Project's homepage</a><br>JAMSS output is very verbose and very useful, hover over any lines to see the details."
COM_JEDCHECKER_ERROR_JAMSS_SUSPICIOUS_FILENAME="Suspicious filename found :"

View File

@ -158,6 +158,13 @@ class JedcheckerRulesFramework extends JEDcheckerRule
$result = true;
}
// Report spaces/tabs/EOLs at the beginning of file
if (strpos(" \t\n\r\v\f", $content[0]) !== false)
{
$this->report->addNotice($file, JText::_('COM_JEDCHECKER_ERROR_FRAMEWORK_LEADING_SPACES'));
$result = true;
}
// Clean non-code
$content = JEDCheckerHelper::cleanPhpCode(
$content,