diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2024-01-29 19:10:57 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-29 19:10:57 +0800 |
| commit | 2e357dddcf4bfe2f1d347bf0b8ff34edbd21fd5e (patch) | |
| tree | 2a9b3bf55dcdc499221cefd37a84ed90ab86c668 /public | |
| parent | 4cc96522c17238211e224fc43d34dcbc335d7436 (diff) | |
| parent | f2e9b102e9911bd385ad2444ae71ee420c70395d (diff) | |
Merge pull request #7 from littleblack111/4-fix-code-scanning-alert-dom-text-reinterpreted-as-html
fixed all cwv by adding a escapeTextReinterpreted function
Diffstat (limited to 'public')
| -rw-r--r-- | public/js/getrepo.js | 6 | ||||
| -rw-r--r-- | public/js/main.js | 3 |
2 files changed, 6 insertions, 3 deletions
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<h2 class=\"repo-title\">".concat(repo.name, "</h2>\n\t\t\t<span class=\"rdescription\">").concat(repo.description ? "<span class=\"rdescriptiontext\">".concat(repo.description, "</span>") : '', "<br/><br/>"); + listItem.innerHTML = escapeTextReinterpreted("\n\t\t\t<h2 class=\"repo-title\">".concat(repo.name, "</h2>\n\t\t\t<span class=\"rdescription\">").concat(repo.description ? "<span class=\"rdescriptiontext\">".concat(repo.description, "</span>") : '', "<br/><br/>")); if (repo.stargazers_count > 0) { - listItem.innerHTML += "<a href=\"".concat(starsUrl, "\">\n\t\t\t<span>\u2B50 ").concat(repo.stargazers_count, "</span></a>"); + listItem.innerHTML += escapeTextReinterpreted("<a href=\"".concat(starsUrl, "\">\n\t\t\t<span>\u2B50 ").concat(repo.stargazers_count, "</span></a>")); } if (repo.language) { listItem.innerHTML += "<a href=\"".concat(langUrl, "\">\n\t\t\t<span>").concat(devicons[repo.language], "</span></a>"); } if (repo.forks_count > 0) { - listItem.innerHTML += "<a href=\"".concat(starsUrl, "\">\n\t\t\t<span>").concat(devicons["Git"], " ").concat(repo.forks_count, "</span></a>"); + listItem.innerHTML += escapeTextReinterpreted("<a href=\"".concat(starsUrl, "\">\n\t\t\t<span>").concat(devicons["Git"], " ").concat(repo.forks_count, "</span></a>")); } if (repo.homepage && repo.homepage !== "") { listItem.innerHTML += "<br /> <br />\n\t\t\t<a class=\"link-btn btn-code\" href=".concat(repo.html_url, ">Code ").concat(devicons["Github"], "</a>\n\t\t\t<a class=\"link-btn btn-live\" href=").concat(repo.homepage, ">Live ").concat(devicons["Chrome"], "</a> <br />"); 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, """).replace(/'/g, "'"); }
\ No newline at end of file |
