From 9c6295231eb4f4829d7089d6209a2c609192c7bc Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Tue, 9 Mar 2021 23:43:21 +0300 Subject: [PATCH] Check for incorrect EOL --- .../language/en-GB/en-GB.com_jedchecker.ini | 1 + .../com_jedchecker/libraries/rules/language.php | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini index 88c4545..dba071f 100644 --- a/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini +++ b/administrator/components/com_jedchecker/language/en-GB/en-GB.com_jedchecker.ini @@ -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_INCORRECT_EOL="Incorrect end-of-line character found. Convert file to Unix EOL (\n) format." 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" diff --git a/administrator/components/com_jedchecker/libraries/rules/language.php b/administrator/components/com_jedchecker/libraries/rules/language.php index 1f141ef..fe9ac4b 100644 --- a/administrator/components/com_jedchecker/libraries/rules/language.php +++ b/administrator/components/com_jedchecker/libraries/rules/language.php @@ -79,6 +79,19 @@ class JedcheckerRulesLanguage extends JEDcheckerRule */ protected function find($file, $tag) { + $content = file_get_contents($file); + + if ($content === false) + { + return false; + } + + // Check EOL format is \n (not \r or \n\r) + if (strpos($content, "\r") !== false) + { + $this->report->addWarning($file, JText::_('COM_JEDCHECKER_LANG_INCORRECT_EOL')); + } + $lines = file($file); $nLines = count($lines); $keys = array();