33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-11-30 16:53:59 +00:00

Check for incorrect EOL

This commit is contained in:
Denis Ryabov 2021-03-09 23:43:21 +03:00
parent 778ece5631
commit 9c6295231e
2 changed files with 14 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_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"

View File

@ -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();