lint_locales 691 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. set -e
  3. TEMPLATES_EXTENDING_META_BLOCK=$(\
  4. grep \
  5. --files-with-matches \
  6. --recursive locales/ \
  7. --regex "'" \
  8. || echo "all-good"
  9. )
  10. if [[ "$TEMPLATES_EXTENDING_META_BLOCK" == "all-good" ]]; then
  11. exit 0
  12. fi
  13. for file in ${TEMPLATES_EXTENDING_META_BLOCK}; do
  14. cat <<MSG >&2
  15. ERROR: $file contains a locale with a single quote.
  16. ---
  17. $(grep "$file" --regex "'")
  18. ---
  19. Using single quotes in locales can lead to Angular XSS.
  20. You will need to replace the quote with a similar looking character.
  21. ’ (\u2019) is a good candidate.
  22. Links:
  23. - https://en.wikipedia.org/wiki/Right_single_quotation_mark
  24. - https://github.com/overleaf/issues/issues/4478
  25. MSG
  26. exit 1
  27. done