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:
@@ -615,6 +615,16 @@ lexer_parse_string (parser_context_t *context_p) /**< context */
|
|||||||
continue;
|
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
|
/* Except \x, \u, and octal numbers, everything is
|
||||||
* converted to a character which has the same byte length. */
|
* converted to a character which has the same byte length. */
|
||||||
if (*source_p >= LIT_CHAR_0 && *source_p <= LIT_CHAR_3)
|
if (*source_p >= LIT_CHAR_0 && *source_p <= LIT_CHAR_3)
|
||||||
|
|||||||
@@ -70,6 +70,52 @@ try
|
|||||||
assert (e instanceof TypeError);
|
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) {
|
||||||
(function (a) {
|
(function (a) {
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user