lint_pug_templates 803 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/sh
  2. set -e
  3. TEMPLATES_EXTENDING_META_BLOCK=$(\
  4. grep \
  5. --files-with-matches \
  6. --recursive app/views modules/*/app/views \
  7. --regex 'block append meta' \
  8. --regex 'block prepend meta' \
  9. --regex 'append meta' \
  10. --regex 'prepend meta' \
  11. )
  12. for file in ${TEMPLATES_EXTENDING_META_BLOCK}; do
  13. if ! grep "$file" --quiet --extended-regexp -e 'extends .+layout'; then
  14. cat <<MSG >&2
  15. ERROR: $file is a partial template and extends 'block meta'.
  16. Using block append/prepend in a partial will duplicate the block contents into
  17. the <body> due to a bug in pug.
  18. Putting meta tags in the <body> can lead to Angular XSS.
  19. You will need to refactor the partial and move the block into the top level
  20. page template that extends the global layout.pug.
  21. MSG
  22. exit 1
  23. fi
  24. done