Skip to content

Commit 439ded4

Browse files
authored
Escape the JSON-LD against early script termination (#4462)
Follow-up to #4458. `JSON.stringify` leaves `<` unescaped, so a `</script>` inside any `siteConfig` value would close the script tag early. Escaped to `\u003c`. Raised by Copilot on the same plugin in react-native-enriched-html#782; this is the same one-line fix.
1 parent 8a4d05d commit 439ded4

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

packages/docs-gesture-handler/plugins/swm-geo.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ module.exports = function swmGeoPlugin(context) {
116116
{
117117
tagName: 'script',
118118
attributes: { type: 'application/ld+json' },
119-
innerHTML: JSON.stringify(buildStructuredData(context.siteConfig)),
119+
innerHTML: JSON.stringify(
120+
buildStructuredData(context.siteConfig)
121+
).replace(/</g, '\\u003c'),
120122
},
121123
],
122124
};

0 commit comments

Comments
 (0)