Sanitize user attached images. Constrain chat input width on home page

Set max combined images size to 20mb to allow multiple photos to be shared
This commit is contained in:
Debanjum Singh Solanky
2024-10-22 19:13:54 -07:00
parent 6c393800cc
commit b3fff43542
3 changed files with 9 additions and 6 deletions

View File

@@ -343,10 +343,13 @@ const ChatMessage = forwardRef<HTMLDivElement, ChatMessageProps>((props, ref) =>
if (props.chatMessage.images && props.chatMessage.images.length > 0) {
const imagesInMd = props.chatMessage.images
.map(
(image, index) =>
`<div class="${styles.imageWrapper}"><img src="${image.startsWith("data%3Aimage") ? decodeURIComponent(image) : image}" alt="uploaded image ${index + 1}" /></div>`,
)
.map((image, index) => {
const decodedImage = image.startsWith("data%3Aimage")
? decodeURIComponent(image)
: image;
const sanitizedImage = DOMPurify.sanitize(decodedImage);
return `<div class="${styles.imageWrapper}"><img src="${sanitizedImage}" alt="uploaded image ${index + 1}" /></div>`;
})
.join("");
message = `<div class="${styles.imagesContainer}">${imagesInMd}</div>${message}`;
}