Skip to content

Conversation

@prafull-opensignlabs
Copy link
Collaborator

No description provided.

<img
alt="print img"
ref={imageRef}
src={image.src}

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.
DOM text
is reinterpreted as HTML without escaping meta-characters.

Copilot Autofix

AI 8 months ago

To fix the issue, we need to sanitize or validate the e.target.value input before it is assigned to widgetValue and subsequently used in the DOM. A good approach is to use a library like DOMPurify to sanitize the input or validate the input to ensure it is a safe URL. This ensures that any potentially harmful content is removed before rendering.

The changes will involve:

  1. Importing DOMPurify for sanitization.
  2. Sanitizing e.target.value in the handleOnchangeTextBox function before assigning it to widgetValue.
Suggested changeset 2
apps/OpenSign/src/components/pdf/WidgetsValueModal.jsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/OpenSign/src/components/pdf/WidgetsValueModal.jsx b/apps/OpenSign/src/components/pdf/WidgetsValueModal.jsx
--- a/apps/OpenSign/src/components/pdf/WidgetsValueModal.jsx
+++ b/apps/OpenSign/src/components/pdf/WidgetsValueModal.jsx
@@ -1,2 +1,3 @@
 import React, { forwardRef, useEffect, useRef, useState } from "react";
+import DOMPurify from "dompurify";
 import ModalUi from "../../primitives/ModalUi";
@@ -932,5 +933,6 @@
     setIsShowValidation(false);
-    setWidgetValue(e.target.value);
+    const sanitizedValue = DOMPurify.sanitize(e.target.value);
+    setWidgetValue(sanitizedValue);
     onChangeInput(
-      e.target.value,
+      sanitizedValue,
       currWidgetsDetails?.key,
EOF
@@ -1,2 +1,3 @@
import React, { forwardRef, useEffect, useRef, useState } from "react";
import DOMPurify from "dompurify";
import ModalUi from "../../primitives/ModalUi";
@@ -932,5 +933,6 @@
setIsShowValidation(false);
setWidgetValue(e.target.value);
const sanitizedValue = DOMPurify.sanitize(e.target.value);
setWidgetValue(sanitizedValue);
onChangeInput(
e.target.value,
sanitizedValue,
currWidgetsDetails?.key,
apps/OpenSign/package.json
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/OpenSign/package.json b/apps/OpenSign/package.json
--- a/apps/OpenSign/package.json
+++ b/apps/OpenSign/package.json
@@ -54,3 +54,4 @@
     "web-vitals": "^5.0.1",
-    "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
+    "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
+    "dompurify": "^3.2.6"
   },
EOF
@@ -54,3 +54,4 @@
"web-vitals": "^5.0.1",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
"dompurify": "^3.2.6"
},
This fix introduces these dependencies
Package Version Security advisories
dompurify (npm) 3.2.6 None
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
@vercel
Copy link

vercel bot commented May 28, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
open-sign ✅ Ready (Inspect) Visit Preview May 28, 2025 5:54am

@prafull-opensignlabs prafull-opensignlabs merged commit 9b357ac into main May 28, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants