The goal of this code is to check for a consecutive &, b, u, and =. However, when I input my code through Javascript injection, it crashes the webpage.
Code:
var str = document.URL; //gets URL of webpage
var copied = 0;
//this loop reads the URL character by character and checks if it is an &, b, u, or =. If so, it sets the corresponding variables to 1.
for (var i = 0; i < 1; i++) {
var res = str.charAt(i);
if (res == "&") {
var ampYes = 1;
} else {
var ampYes = 0;
}
if (res == "b") {
var bYes = 1;
} else {
var bYes = 0;
}
if (res == "u") {
var uYes = 1;
} else {
var uYes = 0;
}
if (res == "=") {
var eqYes = 1;
} else {
var eqYes = 0;
}
alert(res)
}
I presume that the reason it's crashing is due to an error in one of my "if"s. I tested it on a website without an ampersand and it didn't crash. However, on a website with a consecutive &, b, u, and =, it crashed the page.