corrections for octal escape sequences; allows "\0" alone; see #1547
Relevant sections of the spec: * http://es5.github.com/#C * http://es5.github.com/#B.1.2 * http://es5.github.com/#x7.8.4
This commit is contained in:
parent
eabcb2c8b0
commit
46ff7705ee
|
@ -168,7 +168,7 @@
|
|||
default:
|
||||
return 0;
|
||||
}
|
||||
if (octalEsc = /^(?:\\.|[^\\])*\\[0-7]/.test(string)) {
|
||||
if (octalEsc = /^(?:\\.|[^\\])*\\(?:0[0-7]|[1-7])/.test(string)) {
|
||||
this.error("octal escape sequences " + string + " are not allowed");
|
||||
}
|
||||
this.line += count(string, '\n');
|
||||
|
|
|
@ -164,7 +164,7 @@ exports.Lexer = class Lexer
|
|||
@token 'STRING', @escapeLines string
|
||||
else
|
||||
return 0
|
||||
if octalEsc = /^(?:\\.|[^\\])*\\[0-7]/.test string
|
||||
if octalEsc = /^(?:\\.|[^\\])*\\(?:0[0-7]|[1-7])/.test string
|
||||
@error "octal escape sequences #{string} are not allowed"
|
||||
@line += count string, '\n'
|
||||
string.length
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
|
||||
# helper to assert that code complies with strict prohibitions
|
||||
strict = (code, msg) ->
|
||||
throws (-> CoffeeScript.compile code), null, msg
|
||||
throws (-> CoffeeScript.compile code), null, msg ? code
|
||||
strictOk = (code, msg) ->
|
||||
doesNotThrow (-> CoffeeScript.compile code), msg
|
||||
doesNotThrow (-> CoffeeScript.compile code), msg ? code
|
||||
|
||||
|
||||
test "octal integer literals prohibited", ->
|
||||
|
@ -32,19 +32,28 @@ test "octal integer literals prohibited", ->
|
|||
strictOk '`01`'
|
||||
|
||||
test "octal escape sequences prohibited", ->
|
||||
strict '"\\0"'
|
||||
strict '"\\1"'
|
||||
strict '"\\7"'
|
||||
strict '"\\000"'
|
||||
strict '"\\001"'
|
||||
strict '"\\777"'
|
||||
strict '"_\\0"'
|
||||
strict '"\\0_"'
|
||||
strict '"_\\0_"'
|
||||
strict '"\\08"'
|
||||
strict '"\\\\\\0"'
|
||||
strict '"_\\1"'
|
||||
strict '"\\1_"'
|
||||
strict '"_\\1_"'
|
||||
strict '"\\\\\\1"'
|
||||
strictOk '"\\0"'
|
||||
eq "\x00", "\0"
|
||||
strictOk '"\\08"'
|
||||
eq "\x008", "\08"
|
||||
strictOk '"\\0\\8"'
|
||||
eq "\x008", "\0\8"
|
||||
strictOk '"\\8"'
|
||||
strictOk '"\\\\0"'
|
||||
strictOk '"\\\\\\\\0"'
|
||||
strictOk "`'\\0'`"
|
||||
eq "8", "\8"
|
||||
strictOk '"\\\\1"'
|
||||
eq "\\" + "1", "\\1"
|
||||
strictOk '"\\\\\\\\1"'
|
||||
eq "\\\\" + "1", "\\\\1"
|
||||
strictOk "`'\\1'`"
|
||||
eq "\\" + "1", `"\\1"`
|
||||
|
||||
|
||||
test "duplicate property definitions in object literals are prohibited", ->
|
||||
|
|
Loading…
Reference in New Issue