mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Allow "<NUL>" character within string literals in strict mode
JerryScript-DCO-1.0-Signed-off-by: Yanhui Shen shen.elf@gmail.com
This commit is contained in:
parent
522c7d3f87
commit
b32e5444d8
@ -615,6 +615,16 @@ lexer_parse_string (parser_context_t *context_p) /**< context */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (*source_p == LIT_CHAR_0
|
||||
&& source_p + 1 < source_end_p
|
||||
&& (*(source_p + 1) < LIT_CHAR_0 || *(source_p + 1) > LIT_CHAR_9))
|
||||
{
|
||||
source_p++;
|
||||
column++;
|
||||
length++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Except \x, \u, and octal numbers, everything is
|
||||
* converted to a character which has the same byte length. */
|
||||
if (*source_p >= LIT_CHAR_0 && *source_p <= LIT_CHAR_3)
|
||||
|
||||
@ -70,6 +70,52 @@ try
|
||||
assert (e instanceof TypeError);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
eval ("'\\" + "101'");
|
||||
|
||||
assert (false);
|
||||
} catch (e)
|
||||
{
|
||||
assert (e instanceof SyntaxError);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var str1 = "'\\" + "0'";
|
||||
var str2 = "'\\x" + "00'";
|
||||
eval (str1);
|
||||
|
||||
assert (eval (str1) === eval (str2));
|
||||
} catch (e)
|
||||
{
|
||||
assert (false);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var str1 = "'\\" + "0" + "\\" + "0" + "\\" + "0'";
|
||||
var str2 = "'\\x" + "00" + "\\x" + "00" + "\\x" + "00'";
|
||||
eval (str1);
|
||||
|
||||
assert (eval (str1) === eval (str2));
|
||||
} catch (e)
|
||||
{
|
||||
assert (false);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var str1 = "'foo\\" + "0" + "bar'";
|
||||
var str2 = "'foo\\x" + "00" + "bar'";
|
||||
eval (str1);
|
||||
|
||||
assert (eval (str1) === eval (str2));
|
||||
} catch (e)
|
||||
{
|
||||
assert (false);
|
||||
}
|
||||
|
||||
(function (a) {
|
||||
(function (a) {
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user