Fix unsafe location.hash usage in saveBuild
This commit is contained in:
parent
890b5252f0
commit
a42db4128a
1 changed files with 4 additions and 3 deletions
|
@ -889,14 +889,15 @@ function saveBuild() {
|
||||||
if (player_build) {
|
if (player_build) {
|
||||||
let savedBuilds = window.localStorage.getItem("builds") === null ? {} : JSON.parse(window.localStorage.getItem("builds"));
|
let savedBuilds = window.localStorage.getItem("builds") === null ? {} : JSON.parse(window.localStorage.getItem("builds"));
|
||||||
let saveName = document.getElementById("build-name").value;
|
let saveName = document.getElementById("build-name").value;
|
||||||
if ((!Object.keys(savedBuilds).includes(saveName) || document.getElementById("saved-error").textContent !== "") && location.hash !== "") {
|
let encodedBuild = encodeBuild();
|
||||||
savedBuilds[saveName] = location.hash.replace("#", "");
|
if ((!Object.keys(savedBuilds).includes(saveName) || document.getElementById("saved-error").textContent !== "") && encodedBuild !== "") {
|
||||||
|
savedBuilds[saveName] = encodedBuild.replace("#", "");
|
||||||
window.localStorage.setItem("builds", JSON.stringify(savedBuilds));
|
window.localStorage.setItem("builds", JSON.stringify(savedBuilds));
|
||||||
|
|
||||||
document.getElementById("saved-error").textContent = "";
|
document.getElementById("saved-error").textContent = "";
|
||||||
document.getElementById("saved-build").textContent = "Build saved";
|
document.getElementById("saved-build").textContent = "Build saved";
|
||||||
} else {
|
} else {
|
||||||
if (location.hash === "")
|
if (encodedBuild === "")
|
||||||
document.getElementById("saved-error").textContent = "Empty build";
|
document.getElementById("saved-error").textContent = "Empty build";
|
||||||
else
|
else
|
||||||
document.getElementById("saved-error").textContent = "Exists. Overwrite?";
|
document.getElementById("saved-error").textContent = "Exists. Overwrite?";
|
||||||
|
|
Loading…
Reference in a new issue