layout: CONSTRAINED generates invalid HTML #37240
Labels
topic: media
Related to gatsby-plugin-image, or general image/media processing topics
type: bug
An issue or pull request relating to a bug in Gatsby
Preliminary Checks
Description
We are we are getting HTML validation errors when using the GatsbyImage component - and I've tracked it down to the placeholder SVG.
Error: Bad value “data:image/svg+xml;charset=utf-8,%3Csvg height='91' width='128' xmlns='http://www.w3.org/2000/svg' version='1.1'%3E%3C/svg%3E” for attribute “src” on element “img”: Illegal character in scheme data: space is not allowed.
Reproduction Link
(n/a)
Steps to Reproduce
Using: "gatsby-plugin-image": "^2.19.0",
And the default component (with placeholder=NONE, layout=CONSTRAINED)
A dummy SVG is injected into the dom to save space by LayoutWrapper. The image data for this SVG is incorrectly escaped.
Expected Result
No lighthouse/html validation issues with placeholder components in GatsbyImage.
Actual Result
The image generated is
Which appears to be the placeholder generated by this block of code
gatsby/packages/gatsby-plugin-image/src/components/layout-wrapper.tsx
Line 85 in 20ef7c1
The error appears for us in lighthouse, https://validator.w3.org/nu/#textarea, and also when we run html-validate-cli against the public/index.html for the site.
The error disappears when I swap the query in GQL to FULL_WIDTH. This skips the layout sizer stuff.
Environment
Config Flags
No
The text was updated successfully, but these errors were encountered: