Merge pull request #3774 from overleaf/jpa-meta

[frontend] import meta tag processing from das7pads fork

GitOrigin-RevId: ca74ff9fbbcb51091a626a45468ff3d24d6136ca
This commit is contained in:
Jakob Ackermann
2021-03-23 03:05:12 +00:00
committed by Copybot
parent 2e305f36bc
commit 535c97e8cf
8 changed files with 135 additions and 47 deletions
+31
View File
@@ -0,0 +1,31 @@
#!/bin/sh
set -e
TEMPLATES_EXTENDING_META_BLOCK=$(\
grep \
--files-with-matches \
--recursive app/views modules/*/app/views \
--regex 'block append meta' \
--regex 'block prepend meta' \
--regex 'append meta' \
--regex 'prepend meta' \
)
for file in ${TEMPLATES_EXTENDING_META_BLOCK}; do
if ! grep "$file" --quiet --extended-regexp -e 'extends .+layout'; then
cat <<MSG >&2
ERROR: $file is a partial template and extends 'block meta'.
Using block append/prepend in a partial will duplicate the block contents into
the <body> due to a bug in pug.
Putting meta tags in the <body> can lead to Angular XSS.
You will need to refactor the partial and move the block into the top level
page template that extends the global layout.pug.
MSG
exit 1
fi
done