From b75bc8bee3e37f93edb1a8fdd2b99f4cba5254ec Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Mon, 18 Nov 2024 05:53:39 +0530 Subject: [PATCH] suggestions --- src/components/Common/MarkdownPreview.tsx | 14 ++++++++++++-- src/components/Facility/DoctorNote.tsx | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/Common/MarkdownPreview.tsx b/src/components/Common/MarkdownPreview.tsx index f20b89fe766..e4a353fd231 100644 --- a/src/components/Common/MarkdownPreview.tsx +++ b/src/components/Common/MarkdownPreview.tsx @@ -46,16 +46,26 @@ const MarkdownPreview = ({ title?: string | null; text: string; }) { + try { + const url = new URL(href); + if (!["http:", "https:"].includes(url.protocol)) { + return text; + } + href = url.toString(); + } catch { + return text; + } return `${text}`; }; const processedMarkdown = markdown - .replace(/@(\w+)/g, (_, username) => { + .replace(/@([a-zA-Z0-9_]{3,30})/g, (_, username) => { const user = MentionedUsers[username]; if (user) { - return `@${username}`; + const sanitizedUsername = username.replace(/[<>"'&]/g, ""); + return `@${sanitizedUsername}`; } else { return `@${username}`; } diff --git a/src/components/Facility/DoctorNote.tsx b/src/components/Facility/DoctorNote.tsx index 19300b67c7c..5b6fbcd538f 100644 --- a/src/components/Facility/DoctorNote.tsx +++ b/src/components/Facility/DoctorNote.tsx @@ -10,7 +10,7 @@ import { interface DoctorNoteProps { state: PatientNoteStateType; - setReload: any; + setReload?: (value: boolean) => void; handleNext: () => void; disableEdit?: boolean; setReplyTo?: (reply_to: PatientNotesModel | undefined) => void;