From f2e9b102e9911bd385ad2444ae71ee420c70395d Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Mon, 29 Jan 2024 19:10:20 +0800 Subject: fixed all cwv by adding a escapeTextReinterpreted function --- public/js/getrepo.js | 6 +++--- public/js/main.js | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'public') diff --git a/public/js/getrepo.js b/public/js/getrepo.js index b78eb30a..93a9c45a 100644 --- a/public/js/getrepo.js +++ b/public/js/getrepo.js @@ -91,15 +91,15 @@ var displayRepos = function displayRepos(repos) { var forksUrl = "".concat(userHome, "/").concat(repo.name, "/network/members"); var listItem = document.createElement('li'); listItem.classList.add('repo', 'animate', 'zoomIn'); - listItem.innerHTML = "\n\t\t\t

".concat(repo.name, "

\n\t\t\t").concat(repo.description ? "".concat(repo.description, "") : '', "

"); + listItem.innerHTML = escapeTextReinterpreted("\n\t\t\t

".concat(repo.name, "

\n\t\t\t").concat(repo.description ? "".concat(repo.description, "") : '', "

")); if (repo.stargazers_count > 0) { - listItem.innerHTML += "\n\t\t\t\u2B50 ").concat(repo.stargazers_count, ""); + listItem.innerHTML += escapeTextReinterpreted("\n\t\t\t\u2B50 ").concat(repo.stargazers_count, "")); } if (repo.language) { listItem.innerHTML += "\n\t\t\t").concat(devicons[repo.language], ""); } if (repo.forks_count > 0) { - listItem.innerHTML += "\n\t\t\t").concat(devicons["Git"], " ").concat(repo.forks_count, ""); + listItem.innerHTML += escapeTextReinterpreted("\n\t\t\t").concat(devicons["Git"], " ").concat(repo.forks_count, "")); } if (repo.homepage && repo.homepage !== "") { listItem.innerHTML += "

\n\t\t\tCode ").concat(devicons["Github"], "\n\t\t\tLive ").concat(devicons["Chrome"], "
"); diff --git a/public/js/main.js b/public/js/main.js index e7a44b6a..323dae9e 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -6,4 +6,7 @@ if ('serviceWorker' in navigator) { console.log('sw.js failed: ', err); }); }); +} +function escapeTextReinterpreted(htmlStr) { + return htmlStr.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'"); } \ No newline at end of file -- cgit v1.2.3