ASCII null character in script

31 views
Skip to first unread message

Danny Dorfman

unread,
Mar 16, 2017, 6:05:21 AM3/16/17
to v8-users
Hello there,

I have been given a script sample that contains a null character (ASCII 0x00).

<html>
<body>
<script>
    alert("I am an alert box!");
    ^@
</script>   
</body>
</html>

Obviously, this fails to compile and run, since this is not valid syntax (I get "SyntaxError: Invalid or unexpected token").
However, in IE this code just gives out a warning, and runs normally.

Is it possible to simulate the IE behavior under V8 as well?

Thanks in advance,
D.

Daniel Ehrenberg

unread,
Mar 16, 2017, 7:06:25 AM3/16/17
to v8-u...@googlegroups.com
V8 works towards implementing the ECMAScript spec, which you can find at https://tc39.github.io/ecma262/ . It doesn't provide any compatibility modes for other versions of JavaScript shipped by particular browsers, or historical versions of JavaScript. In standard JS, the null byte is not a whitespace character, so it makes sense for V8 to throw a SyntaxError.

Dan

--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages