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

fix(gatsby): prevent escaping textContent for scripts #36174

Merged
merged 6 commits into from Jul 20, 2022

Conversation

marvinjude
Copy link
Contributor

@marvinjude marvinjude commented Jul 19, 2022

Description

Prevent auto escaping of textContent for <script> tags.

See Discussion

Documentation

https://www.gatsbyjs.com/docs/how-to/adding-common-features/adding-seo-component/#rich-snippets

[sc-53448]

@marvinjude marvinjude added the type: bug An issue or pull request relating to a bug in Gatsby label Jul 19, 2022
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jul 19, 2022
@marvinjude marvinjude removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jul 19, 2022
@LekoArts LekoArts added topic: DX Developer Experience (e.g. Fast Refresh, i18n, SSR, page creation, starters) and removed type: bug An issue or pull request relating to a bug in Gatsby labels Jul 20, 2022
@LekoArts LekoArts added this to To cherry-pick in V4 Release hotfixes via automation Jul 20, 2022
@marvinjude marvinjude changed the title fix(gatsby): prevent escaping textContent for <script> data blocks fix(gatsby): prevent escaping textContent for head elements Jul 20, 2022
)
let element
const attributes = { ...node.attributes, "data-gatsby-head": true }
if (rawTagName === `script`) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React isn't happy with doing dangerouslySetInnerHTML on <title> so it makes sense to keep this for scripts alone

@marvinjude marvinjude changed the title fix(gatsby): prevent escaping textContent for head elements fix(gatsby): prevent escaping textContent scripts Jul 20, 2022
@marvinjude marvinjude changed the title fix(gatsby): prevent escaping textContent scripts fix(gatsby): prevent escaping textContent for scripts Jul 20, 2022
@LekoArts LekoArts merged commit d42243c into master Jul 20, 2022
@LekoArts LekoArts deleted the prev-escaping-text-for-data-block branch July 20, 2022 10:45
LekoArts pushed a commit that referenced this pull request Jul 20, 2022
* prevent escaping textContent for <script> data blocks

* fix typo

* touch up

* spread attributes

* add gatsby-head attribute

* unescape for all script tags

(cherry picked from commit d42243c)
@LekoArts LekoArts moved this from To cherry-pick to Backport PR opened in V4 Release hotfixes Jul 20, 2022
LekoArts pushed a commit that referenced this pull request Jul 20, 2022
Co-authored-by: Jude Agboola <marvinjudehk@gmail.com>
@LekoArts LekoArts moved this from Backport PR opened to Backported in V4 Release hotfixes Jul 20, 2022
@LekoArts LekoArts moved this from Backported to Published in V4 Release hotfixes Jul 20, 2022
@LekoArts
Copy link
Contributor

Fixed in gatsby@4.19.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: DX Developer Experience (e.g. Fast Refresh, i18n, SSR, page creation, starters)
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants