lint_locales 964 B

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