Quotation marks in blog post featured image alt text not escaped (security issue)

I noticed that quotation marks in the alt text of blog post featured images are not automatically escaped.

For example, here is how the alt text This is some alt text “with quotation marks.” is rendered as HTML:

<img src="https://{OBSCURED}.fs1.hubspotusercontent-na1.net/hubfs/{OBSCURED}/sample-image.jpeg" loading="lazy" alt="This is some alt text " with="" quotation="" marks.""="">

This seems like an input sanitization issue on Hubspot’s end and a potential security concern.

Steps to reproduce:

1. Create a blog post

2. Enter some text in the alt text of the featured image that contains quotations marks, e.g.This is some alt text “with quotation marks.”

3. Ensure image in the template code renders alt text via the content.featured_image_alt_text Hubl variable

4. Publish post and inspect image element via dev tools

@BradySheridan I was able to reproduce the issue and understand your sercurity concern - I would suggest adding this to the Ideas Discussion so the product team can review for future improvements.

If you share the link back here, I’m happy to upvote and also share in the Developer Slack to help gain some traction.

On a side note, out of curiousity - what’s your use case for adding quotes to alt text?

Alt Text is designed for screenreaders to describe an image and also for SEO to help search bots properly index images, how do the quotes help differentiate the content for these scenarios?

Thanks @Jnix284! I added this to the Ideas Discussion per your recommendation -- here is the link to that post.

In my particular case, my client sometimes attaches featured images containing text alongside a photograph (text embedded in the image itself). In these cases they enter alt text along these lines: A photo of _ with the text “This is some text.” I noticed the escaping issue while working on the front-end component that renders featured images. I decided to go through the featured image alt text of all blog posts and change any instance of double quotes to single quotes.

You’re welcome @BradySheridan, I upvoted your idea!

The example is very helpful, I can see this being used a lot for memes and other images that are used as graphics for blogs or social posts.

For screenreaders and better accessibility, I highly recommend removing “A photo of” from any of your Alt Text as they will already indicate it is an image’s Alt Text that’s being read.

You could try something like this:

Mountains and a river with the words Go Big or Go Home written in large red letters.

This would be more descriptive for both SEO and screenreaders.

That’s a great note that I will definitely put into practice, much appreciated!

you’re welcome @BradySheridan, always happy to help!