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

SchemaDotOrg bugfix: No longer escape the content of "ld+json" during… #184

Merged
merged 3 commits into from Mar 12, 2020

Conversation

apepper
Copy link
Contributor

@apepper apepper commented Apr 24, 2019

… prerender.

Otherwise the script content will be sanitize by react, which yields prerendered pages where schema dot org is not working.

Reported by @dpetryk .

… prerender.

Otherwise the script content will be sanitize by react, which yields prerendered pages where schema dot org is not working.
@apepper apepper requested a review from dcsaszar April 24, 2019 09:00
@dcsaszar
Copy link
Contributor

dcsaszar commented Apr 24, 2019

Thoughts: I‘d rather leave this dangerous option to the developer, instead of enabling it by default.
See json-ld/json-ld.org#390.

What exactly is the reported issue?

@apepper
Copy link
Contributor Author

apepper commented Apr 24, 2019

What exactly is the reported issue?

How to reproduce:

curl https://www.scrivito.com/example-app-updates-75d8282a00406d70 | grep "application/ld+json"

Expected:

<script type="application/ld+json">{"@context":"http://schema.org","@type":"BlogPosting","author":{"@context":"http://schema.org","@type":"Person","name":"Antony Siegert","image":"https://cdn0.scrvt.com/scrival/405a824b3cbf3c48/de6676aadd27/v/7efcbea2d740/Antony-headshot.jpeg"},"datePublished":"2019-03-04","description":"What is new in the Example App?\nThe Example App has been a big part of the Scrivito journey, not only for you – our customers – but also for us as developers. We developed the Example App to showcase some of what could be done when implementing a Scrivito-based app. It is used, every day, to test...","headline":"Example App Updates","image":"https://cdn0.scrvt.com/scrival/424a30fd4efbb522/753f5dd04322/v/daa2f2e61a9b/giovanni-randisi-219945.jpg"}</script>

Actual:

<script type="application/ld+json">{&quot;@context&quot;:&quot;http://schema.org&quot;,&quot;@type&quot;:&quot;BlogPosting&quot;,&quot;author&quot;:{&quot;@context&quot;:&quot;http://schema.org&quot;,&quot;@type&quot;:&quot;Person&quot;,&quot;name&quot;:&quot;Antony Siegert&quot;,&quot;image&quot;:&quot;https://cdn0.scrvt.com/scrival/405a824b3cbf3c48/de6676aadd27/v/7efcbea2d740/Antony-headshot.jpeg&quot;},&quot;datePublished&quot;:&quot;2019-03-04&quot;,&quot;description&quot;:&quot;What is new in the Example App?\nThe Example App has been a big part of the Scrivito journey, not only for you – our customers – but also for us as developers. We developed the Example App to showcase some of what could be done when implementing a Scrivito-based app. It is used, every day, to test...&quot;,&quot;headline&quot;:&quot;Example App Updates&quot;,&quot;image&quot;:&quot;https://cdn0.scrvt.com/scrival/424a30fd4efbb522/753f5dd04322/v/daa2f2e61a9b/giovanni-randisi-219945.jpg&quot;}</script>

Found thru https://search.google.com/structured-data/testing-tool#url=https%3A%2F%2Fwww.scrivito.com%2Fexample-app-updates-75d8282a00406d70

@dcsaszar
Copy link
Contributor

dcsaszar commented Apr 24, 2019

The underlying issue seems to be React too aggressively escaping (namely double quotes in text nodes).
AFAICS facebook/react#14265 would fix the issue. Should we just wait for this to land? WDYT?

Update: facebook/react#3879 is the underlying issue.

Update: if we're going the unsafe workaround route, we should add something like https://github.com/Radagaisus/escape-html-in-json to get back to the safe zone.

@dcsaszar
Copy link
Contributor

Looks like the state of React here isn't going to change soon. How about my proposal of

if we're going the unsafe workaround route, we should add something like https://github.com/Radagaisus/escape-html-in-json to get back to the safe zone.

@apepper
Copy link
Contributor Author

apepper commented Mar 12, 2020

REVIEW (9aeebe8)

  • Added html escaping to SchemaDotOrg.

Copy link
Contributor

@dcsaszar dcsaszar left a comment

Choose a reason for hiding this comment

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

@dcsaszar dcsaszar merged commit f4bbd91 into master Mar 12, 2020
@dcsaszar dcsaszar deleted the SchemaDotOrg_Bugfix branch March 12, 2020 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants