Skip to content

Commit 426bdee

Browse files
Merge pull request #25 from krishnprakash/alert-autofix-1.1
Potential fix for code scanning alert no. 1: DOM text reinterpreted as HTML
2 parents caa508d + e081f3d commit 426bdee

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

js/page.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
$('#small-nav-dropdown').change(function() {
2-
window.location = $(this)
2+
var selectedValue = $(this)
33
.find('option:selected')
4-
.val()
4+
.val();
5+
if (/^https?:\/\/[^\s/$.?#].[^\s]*$/.test(selectedValue)) {
6+
window.location = selectedValue;
7+
} else {
8+
console.error('Invalid URL:', selectedValue);
9+
}
510
})
611

712
const site_tag = 'UA-62780441-30';

0 commit comments

Comments
 (0)