Skip to content

Commit

Permalink
Sanitize user attached image in chat message input pane of web app
Browse files Browse the repository at this point in the history
  • Loading branch information
debanjum committed Sep 12, 2024
1 parent de60ad7 commit b61d825
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/interface/web/app/components/chatInputArea/chatInputArea.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import styles from "./chatInputArea.module.css";
import React, { useEffect, useRef, useState } from "react";

import { uploadDataForIndexing } from "../../common/chatFunctions";
import { Progress } from "@/components/ui/progress";

import DOMPurify from "dompurify";
import "katex/dist/katex.min.css";
import {
ArrowRight,
Expand Down Expand Up @@ -33,8 +31,6 @@ import {
CommandSeparator,
} from "@/components/ui/command";

import { Textarea } from "@/components/ui/textarea";
import { Button } from "@/components/ui/button";
import {
AlertDialog,
AlertDialogAction,
Expand All @@ -43,13 +39,18 @@ import {
AlertDialogHeader,
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
import { Progress } from "@/components/ui/progress";
import { Popover, PopoverContent } from "@/components/ui/popover";
import { PopoverTrigger } from "@radix-ui/react-popover";
import LoginPrompt from "../loginPrompt/loginPrompt";
import { Textarea } from "@/components/ui/textarea";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import { InlineLoading } from "../loading/loading";
import { convertToBGClass } from "@/app/common/colorUtils";

import LoginPrompt from "../loginPrompt/loginPrompt";
import { uploadDataForIndexing } from "../../common/chatFunctions";
import { InlineLoading } from "../loading/loading";

export interface ChatOptions {
[key: string]: string;
}
Expand Down Expand Up @@ -177,7 +178,7 @@ export default function ChatInputArea(props: ChatInputProps) {
const file_extension = file.name.split(".").pop();
if (image_endings.includes(file_extension || "")) {
setImageUploaded(true);
setImagePath(URL.createObjectURL(file));
setImagePath(DOMPurify.sanitize(URL.createObjectURL(file)));
return;
}
}
Expand Down

0 comments on commit b61d825

Please sign in to comment.