Commit aa779b38 authored by mmaly@chromium.org's avatar mmaly@chromium.org

Fix V8 bug 1084: allow "\0" in strict mode as valid escape sequence.

http://code.google.com/p/v8/issues/detail?id=1084

Code Review URL: http://codereview.chromium.org/6386014/

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6550 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a38a8ffa
......@@ -99,9 +99,9 @@ uc32 Scanner::ScanHexEscape(uc32 c, int length) {
// Octal escapes of the forms '\0xx' and '\xxx' are not a part of
// ECMA-262. Other JS VMs support them.
uc32 Scanner::ScanOctalEscape(uc32 c, int length) {
octal_pos_ = source_pos() - 1; // Already advanced
uc32 x = c - '0';
for (int i = 0; i < length; i++) {
int i = 0;
for (; i < length; i++) {
int d = c0_ - '0';
if (d < 0 || d > 7) break;
int nx = x * 8 + d;
......@@ -109,6 +109,12 @@ uc32 Scanner::ScanOctalEscape(uc32 c, int length) {
x = nx;
Advance();
}
// Anything excelt '\0' is an octal escape sequence, illegal in strict mode.
// Remember the position of octal escape sequences so that better error
// can be reported later (in strict mode).
if (c != '0' || i > 0) {
octal_pos_ = source_pos() - i - 1; // Already advanced
}
return x;
}
......
......@@ -409,6 +409,8 @@ class Scanner {
}
uc32 ScanHexEscape(uc32 c, int length);
// Scans octal escape sequence. Also accepts "\0" decimal escape sequence.
uc32 ScanOctalEscape(uc32 c, int length);
// Return the current source position.
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment