Skip to content

Commit

Permalink
Fix code scanning alert no. 17: DOM text reinterpreted as HTML
Browse files Browse the repository at this point in the history
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 3078497 commit 51058d1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Modules/Packages/Detect Age.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import DOMPurify from 'dompurify';
//Detect Age
async function detectAge(data) {
const existingElement = document.querySelector('[data-role="dynamic-image"]') || document.querySelector('video[data-role="dynamic-video"]') || document.querySelector('[data-role="dynamic-dragged"]');
Expand All @@ -23,7 +24,8 @@ async function detectAge(data) {
img.style.maxHeight = '500px';
img.setAttribute('data-role', 'dynamic-image');

const imgSrc = imagedir + data;
const sanitizedData = DOMPurify.sanitize(data);
const imgSrc = imagedir + sanitizedData;
img.src = imgSrc;

// Check if the image source is valid
Expand Down Expand Up @@ -57,7 +59,6 @@ async function detectAge(data) {

// Handle image load error
img.onerror = () => {

echo('Failed to load image.');
};
}

0 comments on commit 51058d1

Please sign in to comment.