31
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-09-28 04:59:04 +00:00

check for BOM in language files

This commit is contained in:
Denis Ryabov 2021-02-23 22:26:09 +03:00
parent 08864234a9
commit b5fe0e91b4
2 changed files with 6 additions and 0 deletions

View File

@ -80,6 +80,7 @@ COM_JEDCHECKER_DELETE_SUCCESS="Temporary folder deleted!"
COM_JEDCHECKER_EMPTY_UPLOAD_FIELD="Please, select a zipped file to be uploaded"
COM_JEDCHECKER_LANG="Language files"
COM_JEDCHECKER_LANG_DESC="Validates language files"
COM_JEDCHECKER_LANG_BOM_FOUND="The byte order mark (BOM) is detected"
COM_JEDCHECKER_LANG_INCORRECT_COMMENT="Incorrect comment character, use ';' instead"
COM_JEDCHECKER_LANG_WRONG_LINE="Incorrect line without '=' character"
COM_JEDCHECKER_LANG_KEY_EMPTY="Empty key name"

View File

@ -77,6 +77,11 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
foreach ($lines as $lineno => $line)
{
$line = trim($line);
if ($lineno === 0 && strncmp($line, "\xEF\xBB\xBF", 3) === 0)
{
$this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_BOM_FOUND'), 1);
$line = substr($line, 3);
}
if ($line === '' || $line[0] === ';' || $line[0] === '[')
{
continue;