2021-08-16 10:59:04 -04:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
2023-01-09 06:20:22 -05:00
|
|
|
|
# Ensure all locale files are sorted.
|
|
|
|
|
node scripts/translations/sort.js --check
|
|
|
|
|
|
2023-01-12 04:51:34 -05:00
|
|
|
|
# Ensure all locales are still in use
|
|
|
|
|
node scripts/translations/cleanupUnusedLocales.js --check
|
|
|
|
|
|
2023-07-20 04:55:40 -04:00
|
|
|
|
# Ensure all locales use the same variables
|
|
|
|
|
node scripts/translations/checkVariables.js --ignore-orphaned-translations
|
|
|
|
|
|
2023-01-09 06:20:22 -05:00
|
|
|
|
# Ensure no locales contain single quotes.
|
|
|
|
|
LOCALES_WITH_SINGLE_QUOTE=$(\
|
2021-08-16 10:59:04 -04:00
|
|
|
|
grep \
|
|
|
|
|
--files-with-matches \
|
|
|
|
|
--recursive locales/ \
|
|
|
|
|
--regex "'" \
|
2023-01-09 06:20:22 -05:00
|
|
|
|
|| true
|
2021-08-16 10:59:04 -04:00
|
|
|
|
)
|
|
|
|
|
|
2023-01-09 06:20:22 -05:00
|
|
|
|
for file in ${LOCALES_WITH_SINGLE_QUOTE}; do
|
2021-08-16 10:59:04 -04:00
|
|
|
|
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
|