Fix parsing of string literals which contain zero character.
JerryScript-DCO-1.0-Signed-off-by: Andrey Shitov a.shitov@samsung.com
This commit is contained in:
@@ -384,11 +384,6 @@ lexer_transform_escape_sequences (const jerry_api_char_t *source_str_p, /**< str
|
|||||||
&& (lit_utf8_iterator_is_eos (&source_str_iter)
|
&& (lit_utf8_iterator_is_eos (&source_str_iter)
|
||||||
|| !lit_char_is_octal_digit (lit_utf8_iterator_peek_next (&source_str_iter))))
|
|| !lit_char_is_octal_digit (lit_utf8_iterator_peek_next (&source_str_iter))))
|
||||||
{
|
{
|
||||||
if (!lit_utf8_iterator_is_eos (&source_str_iter))
|
|
||||||
{
|
|
||||||
lit_utf8_iterator_incr (&source_str_iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
converted_char = LIT_CHAR_NULL;
|
converted_char = LIT_CHAR_NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1031,11 +1026,7 @@ lexer_parse_string (void)
|
|||||||
c = LA (0);
|
c = LA (0);
|
||||||
consume_char ();
|
consume_char ();
|
||||||
|
|
||||||
if (c == LIT_CHAR_NULL)
|
if (lit_char_is_line_terminator (c))
|
||||||
{
|
|
||||||
PARSE_ERROR (JSP_EARLY_ERROR_SYNTAX, "Unclosed string", token_start_pos);
|
|
||||||
}
|
|
||||||
else if (lit_char_is_line_terminator (c))
|
|
||||||
{
|
{
|
||||||
PARSE_ERROR (JSP_EARLY_ERROR_SYNTAX, "String literal shall not contain newline character", token_start_pos);
|
PARSE_ERROR (JSP_EARLY_ERROR_SYNTAX, "String literal shall not contain newline character", token_start_pos);
|
||||||
}
|
}
|
||||||
@@ -1057,7 +1048,12 @@ lexer_parse_string (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (c != end_char);
|
while (c != end_char && !lit_utf8_iterator_is_eos (&src_iter));
|
||||||
|
|
||||||
|
if (c == LIT_CHAR_NULL)
|
||||||
|
{
|
||||||
|
PARSE_ERROR (JSP_EARLY_ERROR_SYNTAX, "Unclosed string", token_start_pos);
|
||||||
|
}
|
||||||
|
|
||||||
const lit_utf8_size_t charset_size = TOK_SIZE () - 2;
|
const lit_utf8_size_t charset_size = TOK_SIZE () - 2;
|
||||||
|
|
||||||
|
|||||||
@@ -18,3 +18,5 @@ try {
|
|||||||
catch (e) {
|
catch (e) {
|
||||||
assert (false);
|
assert (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert ("x\0y" !== "x\0z");
|
||||||
|
|||||||
Reference in New Issue
Block a user