Commit 24c8bbe1 authored by Kaushal Modi's avatar Kaushal Modi

Add "noopener" to rel property for target="_blank" link
parent 6984e7a1
#!/usr/bin/env bash #!/usr/bin/env bash
# Time-stamp: <2017-10-24 10:23:39 kmodi> # Time-stamp: <2017-10-25 10:46:13 kmodi>
# Wrapper script for Netlify/CI hugo builds # Wrapper script for Netlify/CI hugo builds
...@@ -49,6 +49,18 @@ main () { ...@@ -49,6 +49,18 @@ main () {
./hugo -b "${baseurl}" ./hugo -b "${baseurl}"
fi fi
# Open new tabs using `rel="noopener"` to improve performance and prevent
# security vulnerabilities.
echo 'Adding rel="noopener" for target="_blank" links ..'
# - Find all .html files in public/.
# - In those files, then filter down to only the lines that have an <a..>
# tag with *only* href and target properties. This is to prevent false
# search/replace.
# - Then replace «target="_blank"» with «target="_blank" rel="noopener"»
# only in those lines.
find ./public -name "*.html" -exec sed -r -i '/<a href="[^"]+" target="_blank">/ s/target="_blank"/\0 rel="noopener"/g' {} +
echo "Minifying .." echo "Minifying .."
tar xf ./bin/minify_DEV-Linux-64bit.tar.xz tar xf ./bin/minify_DEV-Linux-64bit.tar.xz
./minify --version ./minify --version
Subproject commit ba4476d9222f75d1056854d54c5cb01c25d71180 Subproject commit 306659cdcf41025caa0f06ab19585c9d7e666f97
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment