I have code below of an HTML page that includes a JS file. Function d() receives a String of 24 chars, including 3 non-printable chars (ASCII 005) and counts how many characters are included. This number is displayed with an alert().
- Google Chrome: correctly displays 24 as a result.
- Google Chrome (JS debugger): correctly displays 24 as a result.
- Internet Explorer 9: correctly displays 24 as a result.
- Internet Explorer 9 (JS debugger): displays only 21 (24 – 3 non printable).
I really need this to work with Internet Explorer. Any ideas? THANKS
TEST.HTML
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>JavaScript Scripting</title>
</head>
<body>
<script type="text/javascript" charset="utf-8" src="test.js">
</script>
</body>
</html>
TEST.JS
function d(a){return a.length;};
document.write("<script language=\"Javascript\" charset=\"utf-8\">alert(".concat(d("a[NULL]lert(\"He[NULL]llo Worl[NULL]d\");")).concat(");</script>"));
You should to know when IE lost this bytes! But it looks like it miss them exact on split: check if IE returns true on “” == “\u0005”. Try to avoid using hack like
smth +""use toString() ( what would you get after'Infinity' -0?). Or usevar i= 0; while (a.length) { substr(a, 0, 1); i+=1; //...no IE to test, but could help.UPD
As provided by MSDN IE not in standard mode and less then 9 evaluates
"\v" == "v"as true, so it could be the same with nullchar which causes the string length becomes shorter?