Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

layout: CONSTRAINED generates invalid HTML #37240

Closed
2 tasks done
jfo8001 opened this issue Dec 12, 2022 · 0 comments · Fixed by #37241
Closed
2 tasks done

layout: CONSTRAINED generates invalid HTML #37240

jfo8001 opened this issue Dec 12, 2022 · 0 comments · Fixed by #37241
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

Comments

@jfo8001
Copy link

jfo8001 commented Dec 12, 2022

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

<img alt="" role="presentation" aria-hidden="true" src="data:image/svg+xml;charset=utf-8,%3Csvg height=&#x27;1476&#x27; width=&#x27;2412&#x27; xmlns=&#x27;http://www.w3.org/2000/svg&#x27; version=&#x27;1.1&#x27;%3E%3C/svg%3E" style="max-width:100%;display:block;position:static"/>

Which appears to be the placeholder generated by this block of code

src={`data:image/svg+xml;charset=utf-8,%3Csvg height='${height}' width='${width}' xmlns='http://www.w3.org/2000/svg' version='1.1'%3E%3C/svg%3E`}

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.

       featuredImage {
                                img {
                                    asset {
                                        gatsbyImageData(
                                            placeholder: NONE
                                            layout: FULL_WIDTH 
                                        )
                                    }
                                }
                            }

Environment

System:
    OS: Linux 5.15 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (8) arm64 unknown
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 16.18.1 - /tmp/yarn--1670883985695-0.49910582074023613/node
    Yarn: 1.22.19 - /tmp/yarn--1670883985695-0.49910582074023613/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v16.18.1/bin/npm
  Languages:
    Python: 2.7.18 - /usr/bin/python
  npmPackages:
    gatsby: ^4.19.2 => 4.24.8
    gatsby-plugin-algolia: ^0.26.0 => 0.26.0
    gatsby-plugin-feed-generator: ^2.0.5 => 2.0.5
    gatsby-plugin-gatsby-cloud: ^4.19.0 => 4.24.1
    gatsby-plugin-google-gtag: ^4.19.0 => 4.24.0
    gatsby-plugin-google-tagmanager: ^4.19.0 => 4.24.0
    gatsby-plugin-image: ^2.19.0 => 2.24.0
    gatsby-plugin-layout: ^3.19.0 => 3.24.0
    gatsby-plugin-mailchimp: ^5.1.2 => 5.2.2
    gatsby-plugin-manifest: ^4.19.0 => 4.24.0
    gatsby-plugin-react-helmet: ^5.19.0 => 5.24.0
    gatsby-plugin-remove-serviceworker: ^1.0.0 => 1.0.0
    gatsby-plugin-sharp: ^4.19.0 => 4.24.0
    gatsby-plugin-sitemap: ^5.19.0 => 5.24.0
    gatsby-plugin-styled-components: ^5.19.0 => 5.24.0
    gatsby-plugin-tslint: ^0.0.2 => 0.0.2
    gatsby-plugin-typegen: ^3.0.0 => 3.1.0
    gatsby-plugin-typescript: ^4.19.0 => 4.24.0
    gatsby-plugin-webpack-bundle-analyser-v2: ^1.1.27 => 1.1.30
    gatsby-source-filesystem: ^4.19.0 => 4.24.0
    gatsby-source-graphql: ^4.19.0 => 4.24.0
    gatsby-source-instagram-all: ^5.2.1 => 5.2.1
    gatsby-source-lever: ^4.24.0 => 4.24.0
    gatsby-source-sanity: ^7.4.2 => 7.5.1
    gatsby-transformer-sharp: ^4.19.0 => 4.24.0

Config Flags

No

@jfo8001 jfo8001 added the type: bug An issue or pull request relating to a bug in Gatsby label Dec 12, 2022
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Dec 12, 2022
@LekoArts LekoArts added topic: media Related to gatsby-plugin-image, or general image/media processing topics and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants