From 43423f9453384fc0ab133839c9df3066706cbc83 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Fri, 19 May 2017 10:46:20 +0200 Subject: [PATCH 1/2] GetTextTranslationHelper: Make sure we ignore any dotfile or vendor dir If you are using composer, or ship any other code in dotfile or vendor directories, we should not parse that for translation. Signed-off-by: Eric Lippmann --- .../library/Translation/Util/GettextTranslationHelper.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/translation/library/Translation/Util/GettextTranslationHelper.php b/modules/translation/library/Translation/Util/GettextTranslationHelper.php index eb4b7438c..4a475d165 100644 --- a/modules/translation/library/Translation/Util/GettextTranslationHelper.php +++ b/modules/translation/library/Translation/Util/GettextTranslationHelper.php @@ -467,10 +467,13 @@ class GettextTranslationHelper $subdirs = array(); while (($filename = readdir($directoryHandle)) !== false) { + if ($filename[0] === '.' || $filename === 'vendor') { + continue; + } $filepath = $directory . DIRECTORY_SEPARATOR . $filename; if (preg_match('@^[^\.].+\.(' . implode('|', $this->sourceExtensions) . ')$@', $filename)) { $file->fwrite($filepath . PHP_EOL); - } elseif (is_dir($filepath) && !preg_match('@^(\.|\.\.)$@', $filename)) { + } elseif (is_dir($filepath)) { $subdirs[] = $filepath; } } From 389b23af81188a43004478c3d85c615a53f118fd Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Fri, 13 Oct 2017 13:47:21 +0200 Subject: [PATCH 2/2] GettextTranslationHelper: Avoid descending into symlinks This basically avoids loops... Signed-off-by: Eric Lippmann --- .../library/Translation/Util/GettextTranslationHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/translation/library/Translation/Util/GettextTranslationHelper.php b/modules/translation/library/Translation/Util/GettextTranslationHelper.php index 4a475d165..2fc420fd5 100644 --- a/modules/translation/library/Translation/Util/GettextTranslationHelper.php +++ b/modules/translation/library/Translation/Util/GettextTranslationHelper.php @@ -473,7 +473,7 @@ class GettextTranslationHelper $filepath = $directory . DIRECTORY_SEPARATOR . $filename; if (preg_match('@^[^\.].+\.(' . implode('|', $this->sourceExtensions) . ')$@', $filename)) { $file->fwrite($filepath . PHP_EOL); - } elseif (is_dir($filepath)) { + } elseif (! is_link($filepath) && is_dir($filepath)) { $subdirs[] = $filepath; } }