lint_locales 816 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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 no locales contain single quotes.
  8. LOCALES_WITH_SINGLE_QUOTE=$(\
  9. grep \
  10. --files-with-matches \
  11. --recursive locales/ \
  12. --regex "'" \
  13. || true
  14. )
  15. for file in ${LOCALES_WITH_SINGLE_QUOTE}; do
  16. cat <<MSG >&2
  17. ERROR: $file contains a locale with a single quote.
  18. ---
  19. $(grep "$file" --regex "'")
  20. ---
  21. Using single quotes in locales can lead to Angular XSS.
  22. You will need to replace the quote with a similar looking character.
  23. ’ (\u2019) is a good candidate.
  24. Links:
  25. - https://en.wikipedia.org/wiki/Right_single_quotation_mark
  26. - https://github.com/overleaf/issues/issues/4478
  27. MSG
  28. exit 1
  29. done