Skip to content

Commit 21f587b

Browse files
committed
fix(#1999): sanitize text for ListBox items using DOMPurify
1 parent f7fd1e4 commit 21f587b

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

packages/dev/docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@spectrum-icons/workflow": "^4.0.0",
2626
"algoliasearch": "^4.14.1",
2727
"clsx": "^1.1.1",
28+
"dompurify": "^2.3.10",
2829
"globals-docs": "^2.4.1",
2930
"highlight.js": "^11.6.0",
3031
"markdown-to-jsx": "^6.11.0",

packages/dev/docs/src/client.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import {ActionButton, defaultTheme, Provider, Text} from '@adobe/react-spectrum';
1414
import algoliasearch from 'algoliasearch/lite';
1515
import docsStyle from './docs.css';
16+
import DOMPurify from 'dompurify';
1617
import {Item, SearchAutocomplete, Section} from '@react-spectrum/autocomplete';
1718
import {listen} from 'quicklink';
1819
import React, {useEffect, useRef, useState} from 'react';
@@ -219,11 +220,11 @@ function DocSearch() {
219220
}
220221
section.items.push(
221222
<Item key={objectID} textValue={textValue.join(' | ')}>
222-
<Text><span dangerouslySetInnerHTML={{__html: text.join(' | ')}} /></Text>
223+
<Text><span dangerouslySetInnerHTML={{__html: DOMPurify.sanitize(text.join(' | '))}} /></Text>
223224
{
224225
prediction.content &&
225226
<Text slot="description">
226-
<span dangerouslySetInnerHTML={{__html: prediction._snippetResult.content.value}} />
227+
<span dangerouslySetInnerHTML={{__html: DOMPurify.sanitize(prediction._snippetResult.content.value)}} />
227228
</Text>
228229
}
229230
</Item>

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9616,6 +9616,11 @@ [email protected]:
96169616
resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-2.3.8.tgz#224fe9ae57d7ebd9a1ae1ac18c1c1ca3f532226f"
96179617
integrity sha512-eVhaWoVibIzqdGYjwsBWodIQIaXFSB+cKDf4cfxLMsK0xiud6SE+/WCVx/Xw/UwQsa4cS3T2eITcdtmTg2UKcw==
96189618

9619+
dompurify@^2.3.10:
9620+
version "2.3.10"
9621+
resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-2.3.10.tgz#901f7390ffe16a91a5a556b94043314cd4850385"
9622+
integrity sha512-o7Fg/AgC7p/XpKjf/+RC3Ok6k4St5F7Q6q6+Nnm3p2zGWioAY6dh0CbbuwOhH2UcSzKsdniE/YnE2/92JcsA+g==
9623+
96199624
96209625
version "1.5.1"
96219626
resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.5.1.tgz#dcd8488a26f563d61079e48c9f7b7e32373682cf"

0 commit comments

Comments
 (0)