overleaf/services/web/bin/lint_locales
Jakob Ackermann d0dedd5ef2 Merge pull request #13981 from overleaf/jpa-i18n-ci-lint-fix
[web] split check of extracted-translations from linting of locales

GitOrigin-RevId: bfd5953673ed58e4e7d384129535f4a452cc1041
2023-07-21 08:05:01 +00:00

43 lines
936 B
Bash
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -e
# Ensure all locale files are sorted.
node scripts/translations/sort.js --check
# Ensure all locales are still in use
node scripts/translations/cleanupUnusedLocales.js --check
# Ensure all locales use the same variables
node scripts/translations/checkVariables.js --ignore-orphaned-translations
# Ensure no locales contain single quotes.
LOCALES_WITH_SINGLE_QUOTE=$(\
grep \
--files-with-matches \
--recursive locales/ \
--regex "'" \
|| true
)
for file in ${LOCALES_WITH_SINGLE_QUOTE}; do
cat <<MSG >&2
ERROR: $file contains a locale with a single quote.
---
$(grep "$file" --regex "'")
---
Using single quotes in locales can lead to Angular XSS.
You will need to replace the quote with a similar looking character.
(\u2019) is a good candidate.
Links:
- https://en.wikipedia.org/wiki/Right_single_quotation_mark
- https://github.com/overleaf/issues/issues/4478
MSG
exit 1
done