From 9e7c675219845d80044de6f4664a2fd9964fadc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6?= Date: Fri, 12 Jan 2024 11:23:31 +0100 Subject: [PATCH] fix(translations): sanitize vue translations hints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- .../translationtool/src/translationtool.php | 11 +++++++++-- .../translationtool/translationtool.phar | Bin 416502 -> 416759 bytes 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/translations/translationtool/src/translationtool.php b/translations/translationtool/src/translationtool.php index 0f3754bd..42513563 100644 --- a/translations/translationtool/src/translationtool.php +++ b/translations/translationtool/src/translationtool.php @@ -382,13 +382,20 @@ private function getTranslatorHintWithVueSource(string $vueFile, string $content // // // t('forms', 'Save to home') // TRANSLATORS: Export the file to the home path - $re = '/TRANSLATORS[: ]*(.*)(-->|\n)?/m'; + $re = '/TRANSLATORS[: ]*(.*)/m'; preg_match_all($re, $searchComment, $matches, PREG_SET_ORDER, 0); // If we have a comment, we use it if (count($matches) > 0 && count($matches[0]) > 1) { // Remove double spaces - return str_replace(' ', ' ', '// TRANSLATORS ' . $matches[0][1] . " ($relativeVuePath:$lineNumber)" . PHP_EOL); + $comment = str_replace(' ', ' ', $matches[0][1]); + // Remove leading and trailing spaces + $comment = trim($comment); + // Remove newlines + $comment = str_replace("\n", '', $comment); + // Remove html end comment + $comment = str_replace('-->', '', $comment); + return str_replace(' ', ' ', '// TRANSLATORS ' . $comment . " ($relativeVuePath:$lineNumber)" . PHP_EOL); } return '// TRANSLATORS ' . $relativeVuePath . ':' . $lineNumber . PHP_EOL; diff --git a/translations/translationtool/translationtool.phar b/translations/translationtool/translationtool.phar index 5f642a5911bf6bc86480a08adef90823d49a1c82..20161563f944459a52b9f686f1d61b71912fa4dd 100755 GIT binary patch delta 1489 zcma)*e{54#6vyvlKT6v%3e3=7uYK#8ZjNqXR!?tboHAU)*z+ZLrT;dV!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