From 35756773395cf5dca3718915b559ecb85c577b5c Mon Sep 17 00:00:00 2001 From: Priyankar Pal <88102392+priyankarpal@users.noreply.github.com> Date: Thu, 10 Oct 2024 19:49:40 +0530 Subject: [PATCH] Fix code scanning alert no. 3: DOM text reinterpreted as HTML Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Priyankar Pal <88102392+priyankarpal@users.noreply.github.com> --- src/plays/custommemesgenerator/Meme.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plays/custommemesgenerator/Meme.jsx b/src/plays/custommemesgenerator/Meme.jsx index 0ccebcf12b..66caf6121e 100644 --- a/src/plays/custommemesgenerator/Meme.jsx +++ b/src/plays/custommemesgenerator/Meme.jsx @@ -1,5 +1,6 @@ import React, { useEffect, useState } from 'react'; import axios from 'axios'; +import DOMPurify from 'dompurify'; export default function Meme() { const [memesData, setMemesData] = useState([]); @@ -27,6 +28,7 @@ export default function Meme() { const memesArray = memesData; let randomIndex = Math.floor(Math.random() * memesArray.length); let newUrl = memesArray[randomIndex].url; + newUrl = DOMPurify.sanitize(newUrl); setMeme((prevMeme) => ({ ...prevMeme,