lint_locales 936 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/bash
  2. set -e
  3. # Ensure all locale files are sorted.
  4. node scripts/translations/sort.js --check
  5. # Ensure all locales are still in use
  6. node scripts/translations/cleanupUnusedLocales.js --check
  7. # Ensure all locales use the same variables
  8. node scripts/translations/checkVariables.js --ignore-orphaned-translations
  9. # Ensure no locales contain single quotes.
  10. LOCALES_WITH_SINGLE_QUOTE=$(\
  11. grep \
  12. --files-with-matches \
  13. --recursive locales/ \
  14. --regex "'" \
  15. || true
  16. )
  17. for file in ${LOCALES_WITH_SINGLE_QUOTE}; do
  18. cat <<MSG >&2
  19. ERROR: $file contains a locale with a single quote.
  20. ---
  21. $(grep "$file" --regex "'")
  22. ---
  23. Using single quotes in locales can lead to Angular XSS.
  24. You will need to replace the quote with a similar looking character.
  25. ’ (\u2019) is a good candidate.
  26. Links:
  27. - https://en.wikipedia.org/wiki/Right_single_quotation_mark
  28. - https://github.com/overleaf/issues/issues/4478
  29. MSG
  30. exit 1
  31. done