From ab5cf40393952f57a6177c6e14e6b82bca399073 Mon Sep 17 00:00:00 2001 From: Yash Sarvaiya Date: Tue, 3 Nov 2026 20:34:45 +0530 Subject: [PATCH] fix(react): validate filename and add error handling in AttachmentPreview --- .../src/views/AttachmentPreview/AttachmentPreview.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/react/src/views/AttachmentPreview/AttachmentPreview.js b/packages/react/src/views/AttachmentPreview/AttachmentPreview.js index e6dadeae6..5c6ed5485 100644 --- a/packages/react/src/views/AttachmentPreview/AttachmentPreview.js +++ b/packages/react/src/views/AttachmentPreview/AttachmentPreview.js @@ -70,18 +70,21 @@ const AttachmentPreview = () => { const submit = async () => { if (isPending) return; + if (!fileName || !fileName.trim()) return; if (msgMaxLength && description.length > msgMaxLength) return; setIsPending(true); try { await RCInstance.sendAttachment( data, - fileName, + fileName.trim(), parseEmoji(description), ECOptions?.enableThreads ? threadId : undefined ); toggle(); setData(null); + } catch (error) { + console.error('Error uploading attachment:', error); } finally { setIsPending(false); } @@ -250,7 +253,10 @@ const AttachmentPreview = () => { Cancel -