overleaf/services/web/bin/lint_locales
Jakob Ackermann 99a414f345 Merge pull request #4656 from overleaf/jpa-rewrite-quotes-in-locales
[misc] rewrite single quote to left/right single quotation mark in locales

GitOrigin-RevId: a021fb6841425555b9af79a9146820299cb93fc2
2021-08-17 08:04:49 +00:00

36 lines
691 B
Bash
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -e
TEMPLATES_EXTENDING_META_BLOCK=$(\
grep \
--files-with-matches \
--recursive locales/ \
--regex "'" \
|| echo "all-good"
)
if [[ "$TEMPLATES_EXTENDING_META_BLOCK" == "all-good" ]]; then
exit 0
fi
for file in ${TEMPLATES_EXTENDING_META_BLOCK}; do
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