Skip to content

Commit

Permalink
Fix code scanning alert no. 18: Client-side cross-site scripting
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>
Signed-off-by: Dr. Hans-Peter Störr <999184+stoerr@users.noreply.github.com>
  • Loading branch information
stoerr and github-advanced-security[bot] authored Nov 13, 2024
1 parent 9b85cb5 commit e871fae
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
border: none;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/2.3.4/purify.min.js"></script>

Check warning

Code scanning / CodeQL

Inclusion of functionality from an untrusted source Medium

Script loaded from content delivery network with no integrity check.
</head>
<body>
<div class="iframe-container">
Expand Down Expand Up @@ -62,7 +63,7 @@
leftLoaded = false;
try {
const url = new URL(this.value);
leftIframe.src = url.href;
leftIframe.src = DOMPurify.sanitize(url.href);
} catch (e) {
console.error('Invalid URL:', this.value);
}
Expand All @@ -72,7 +73,7 @@
rightLoaded = false;
try {
const url = new URL(this.value);
rightIframe.src = url.href;
rightIframe.src = DOMPurify.sanitize(url.href);
} catch (e) {
console.error('Invalid URL:', this.value);
}
Expand All @@ -88,11 +89,11 @@
const initialUrl1 = getParameterByName('url1');
const initialUrl2 = getParameterByName('url2');
if (initialUrl1) {
leftIframe.src = initialUrl1;
leftIframe.src = DOMPurify.sanitize(initialUrl1);
leftField.value = initialUrl1;
}
if (initialUrl2) {
rightIframe.src = initialUrl2;
rightIframe.src = DOMPurify.sanitize(initialUrl2);
rightField.value = initialUrl2;
}

Expand Down

0 comments on commit e871fae

Please sign in to comment.