fix possible security issue

This commit is contained in:
smthbh 2025-04-28 20:38:19 -04:00
parent f12e6bae79
commit 20516e1046
2 changed files with 6 additions and 2 deletions

View file

@ -120,7 +120,9 @@ document.addEventListener('DOMContentLoaded', function() {
const [realm, name] = selected.split('/');
// Get the base path by removing everything after /quests/compare/
const basePath = window.location.pathname.split('/quests/compare/')[0];
window.location.href = `${basePath}/quests/compare/${realm}/${name}`;
const safeRealm = encodeURIComponent(realm);
const safeName = encodeURIComponent(name);
window.location.href = `${basePath}/quests/compare/${safeRealm}/${safeName}`;
}
});
});

View file

@ -132,7 +132,9 @@ document.addEventListener('DOMContentLoaded', function() {
const selected = compareSelect.value;
if (selected) {
const [realm, name] = selected.split('/');
window.location.href = `${window.location.pathname}/compare/${realm}/${name}`;
const sanitizedRealm = encodeURIComponent(realm);
const sanitizedName = encodeURIComponent(name);
window.location.href = `${window.location.pathname}/compare/${sanitizedRealm}/${sanitizedName}`;
}
});
});