Skip to content

Commit 038f40e

Browse files
committed
Adds DOMPurify package
1 parent 5374fc4 commit 038f40e

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

apps/webapp/app/components/AskAI.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ import {
55
HandThumbUpIcon,
66
StopIcon,
77
} from "@heroicons/react/20/solid";
8-
import { FeedbackComment, KapaProvider, QA, useChat } from "@kapaai/react-sdk";
8+
import { type FeedbackComment, KapaProvider, type QA, useChat } from "@kapaai/react-sdk";
99
import { useSearchParams } from "@remix-run/react";
1010
import { motion } from "framer-motion";
1111
import { marked } from "marked";
1212
import {
13+
createContext,
14+
type ReactNode,
1315
useCallback,
16+
useContext,
1417
useEffect,
1518
useRef,
1619
useState,
17-
createContext,
18-
useContext,
19-
type ReactNode,
2020
} from "react";
2121
import { AISparkleIcon } from "~/assets/icons/AISparkleIcon";
2222
import { SparkleListIcon } from "~/assets/icons/SparkleListIcon";
@@ -25,7 +25,6 @@ import { Callout } from "./primitives/Callout";
2525
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "./primitives/Dialog";
2626
import { Header2 } from "./primitives/Headers";
2727
import { Paragraph } from "./primitives/Paragraph";
28-
import { ShortcutKey } from "./primitives/ShortcutKey";
2928
import { Spinner } from "./primitives/Spinner";
3029
import {
3130
SimpleTooltip,
@@ -34,6 +33,7 @@ import {
3433
TooltipProvider,
3534
TooltipTrigger,
3635
} from "./primitives/Tooltip";
36+
import DOMPurify from "dompurify";
3737

3838
type AskAIContextType = {
3939
isOpen: boolean;
@@ -257,7 +257,7 @@ function ChatMessages({
257257
<Header2 spacing>{qa.question}</Header2>
258258
<div
259259
className="prose prose-invert max-w-none text-text-dimmed"
260-
dangerouslySetInnerHTML={{ __html: marked(qa.answer) }}
260+
dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(marked(qa.answer)) }}
261261
/>
262262
</div>
263263
))

apps/webapp/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
"cronstrue": "^2.21.0",
125125
"cross-env": "^7.0.3",
126126
"cuid": "^2.1.8",
127+
"dompurify": "^3.2.6",
127128
"dotenv": "^16.4.5",
128129
"effect": "^3.11.7",
129130
"emails": "workspace:*",
@@ -210,6 +211,7 @@
210211
"@types/bcryptjs": "^2.4.2",
211212
"@types/compression": "^1.7.2",
212213
"@types/cookie": "^0.6.0",
214+
"@types/dompurify": "^3.2.0",
213215
"@types/eslint": "^8.4.6",
214216
"@types/express": "^4.17.13",
215217
"@types/humanize-duration": "^3.27.1",

pnpm-lock.yaml

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)