2
Vote

Test 7.8.4-1-s does not correctly check whether octal escape sequences are allowed

description

The spec does not allow octal escape sequences within strict mode code. Test 7.8.4-1-s is designed to check this - however, I believe it fails to do so.
 
The code in question is this: eval(' "asterisk: \052"; "use strict";');
 
The eval function takes a single string and by the time it reaches that point, the escape sequences have been eliminated. Thus the octal escape sequence appears outside strict mode code (i.e. in the context of the testcase function) and thus it should be allowed.
 
Also debatable is whether octal escape sequences should be disallowed before the "use strict" directive is encountered. This seems like it would require the lexer to do a second pass over the code solely to resolve escape sequences.

comments

jwalden wrote Jan 1, 2011 at 10:01 PM

http://es5conform.codeplex.com/workitem/29141 has a patch that also fixes this.

I proposed a fix for your suggestion (directives must not contain escapes, ergo "\052"; "use strict"; would not enter strict mode and require reparsing, or carrying seen-octal state forward when parsing the directive prologue -- SpiderMonkey does the latter because it eagerly throws away source) to the es5-discuss list, but discussion fizzled, and eventually I became fed up on waiting for a definitive yes/no as to making that change and just implemented what the spec requires in SpiderMonkey. https://bugzilla.mozilla.org/show_bug.cgi?id=601262 and https://mail.mozilla.org/pipermail/es5-discuss/2010-October/003745.html are the relevant bug and mailing list discussion. I'd still love it if the spec eliminated the need for this pedantry and reparsing!

wrote Feb 4, 2011 at 9:36 PM

mmaly wrote Feb 4, 2011 at 9:36 PM

We should commit the relevant part of the patch attached to http://es5conform.codeplex.com/workitem/29141.

wrote Feb 13, 2013 at 2:09 AM