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
Conversation
… prerender. Otherwise the script content will be sanitize by react, which yields prerendered pages where schema dot org is not working.
Thoughts: I‘d rather leave this dangerous option to the developer, instead of enabling it by default. What exactly is the reported issue? |
How to reproduce:
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">{"@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> |
The underlying issue seems to be React too aggressively escaping (namely double quotes in text nodes). 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. |
Looks like the state of React here isn't going to change soon. How about my proposal of
|
REVIEW (9aeebe8)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Perfectly in line with https://www.w3.org/TR/json-ld11/#restrictions-for-contents-of-json-ld-script-elements.
… prerender.
Otherwise the script content will be sanitize by react, which yields prerendered pages where schema dot org is not working.
Reported by @dpetryk .