forked from bentaylor2/react-structured-data
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: dangerouslySetInnerHTML property is removed. All the string pro…
…ps will get encoded and dangerouslySetInnerHTML will be used
- Loading branch information
Showing
12 changed files
with
152 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 52 additions & 15 deletions
67
src/core/__tests__/__snapshots__/GenericNode.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,78 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`GenerticNode escapes javascript xss 1`] = ` | ||
<script | ||
dangerouslySetInnerHTML={ | ||
Object { | ||
"__html": "{\\"@context\\":\\"https://schema.org/\\",\\"@type\\":\\"Review\\",\\"reviewBody\\":\\"\\\\\\\\";alert('XSS');//\\"}", | ||
} | ||
} | ||
type="application/ld+json" | ||
/> | ||
`; | ||
|
||
exports[`GenerticNode escapes json xss 1`] = ` | ||
<script | ||
dangerouslySetInnerHTML={ | ||
Object { | ||
"__html": "{\\"@context\\":\\"https://schema.org/\\",\\"@type\\":\\"Review\\",\\"reviewBody\\":\\"</script><script>alert('XSS');</script>\\"}", | ||
} | ||
} | ||
type="application/ld+json" | ||
/> | ||
`; | ||
|
||
exports[`GenerticNode filters out null and false child nodes 1`] = ` | ||
<script | ||
dangerouslySetInnerHTML={ | ||
Object { | ||
"__html": "{\\"@context\\":\\"https://schema.org/\\",\\"@type\\":\\"Review\\",\\"name\\":\\"It is awesome\\",\\"reviewBody\\":\\"This is great!\\",\\"itemReviewed\\":{\\"@type\\":\\"Product\\",\\"@id\\":\\"product-x\\"},\\"locationCreated\\":{\\"@type\\":\\"AdministrativeArea\\",\\"name\\":\\"Chicago, IL\\"}}", | ||
} | ||
} | ||
type="application/ld+json" | ||
> | ||
{"@context":"https://schema.org/","@type":"Review","name":"It is awesome","reviewBody":"This is great!","itemReviewed":{"@type":"Product","@id":"product-x"},"locationCreated":{"@type":"AdministrativeArea","name":"Chicago, IL"}} | ||
</script> | ||
/> | ||
`; | ||
|
||
exports[`GenerticNode filters out one child which is false 1`] = ` | ||
<script | ||
dangerouslySetInnerHTML={ | ||
Object { | ||
"__html": "{\\"@context\\":\\"https://schema.org/\\",\\"@type\\":\\"Review\\",\\"name\\":\\"It is awesome\\"}", | ||
} | ||
} | ||
type="application/ld+json" | ||
> | ||
{"@context":"https://schema.org/","@type":"Review","name":"It is awesome"} | ||
</script> | ||
/> | ||
`; | ||
|
||
exports[`GenerticNode filters out one child which is null 1`] = ` | ||
<script | ||
dangerouslySetInnerHTML={ | ||
Object { | ||
"__html": "{\\"@context\\":\\"https://schema.org/\\",\\"@type\\":\\"Review\\",\\"name\\":\\"It is awesome\\"}", | ||
} | ||
} | ||
type="application/ld+json" | ||
> | ||
{"@context":"https://schema.org/","@type":"Review","name":"It is awesome"} | ||
</script> | ||
/> | ||
`; | ||
|
||
exports[`GenerticNode filters out properties that have null values 1`] = ` | ||
<script | ||
dangerouslySetInnerHTML={ | ||
Object { | ||
"__html": "{\\"@context\\":\\"https://schema.org/\\",\\"@type\\":\\"Review\\",\\"name\\":\\"It is awesome\\"}", | ||
} | ||
} | ||
type="application/ld+json" | ||
> | ||
{"@context":"https://schema.org/","@type":"Review","name":"It is awesome"} | ||
</script> | ||
/> | ||
`; | ||
|
||
exports[`GenerticNode renders question to QAPage mainEntity as Question type 1`] = ` | ||
<script | ||
dangerouslySetInnerHTML={ | ||
Object { | ||
"__html": "{\\"@context\\":\\"https://schema.org/\\",\\"@type\\":\\"Review\\",\\"name\\":\\"It is awesome\\",\\"reviewBody\\":\\"This is great!\\",\\"itemReviewed\\":{\\"@type\\":\\"Product\\",\\"@id\\":\\"product-x\\"},\\"author\\":{\\"@type\\":\\"Person\\",\\"name\\":\\"Cool Carl\\"},\\"locationCreated\\":{\\"@type\\":\\"AdministrativeArea\\",\\"name\\":\\"Chicago, IL\\"}}", | ||
} | ||
} | ||
type="application/ld+json" | ||
> | ||
{"@context":"https://schema.org/","@type":"Review","name":"It is awesome","reviewBody":"This is great!","itemReviewed":{"@type":"Product","@id":"product-x"},"author":{"@type":"Person","name":"Cool Carl"},"locationCreated":{"@type":"AdministrativeArea","name":"Chicago, IL"}} | ||
</script> | ||
/> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters