hugo-shortcode-gallery
hugo-shortcode-gallery copied to clipboard
Javascript code leaks into meta tags and RSS feed
I am not fully sure whether this behavior is caused by the gallery plugin, my theme or Hugo itself.
Most of my posts have a gallery on top (before any other content). This results in the description to look like this (from the RSS feed):
<description>
if (!jQuery) { alert("jquery is not loaded"); } $( document ).ready(() = { const gallery = $("#gallery-0"); let swipeboxInstance = null; gallery.on('jg.complete', () = { $(() = { $('.
</description>
This makes its way into the RSS feed, and the HTML meta tags which will be utilized when sharing on various social media sites.
My workaround is to add an explicit description for each post. However, I still think this is problematic because the default mechanism in many themes is to populate the description from the post content, and it appears that this doesn't filter out Javascript code.
Here's how Hugo populates og:description, and here's my theme's configuration. Finally, this is how Hugo populates the RSS description field.
I had a look at it, but I dont know what I can do on my side to avoid this issue.