Fix multiple JSON.parse issues (#2191)
Fixes #2180, #2192 JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
This commit is contained in:
committed by
Dániel Bátyai
parent
36051ec92b
commit
c429530d02
@@ -161,6 +161,12 @@ ecma_builtin_json_parse_string (ecma_json_token_t *token_p) /**< token argument
|
||||
current_p++;
|
||||
has_escape_sequence = true;
|
||||
|
||||
/* If there is an escape sequence but there's no escapable character just return */
|
||||
if (current_p >= end_p)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (*current_p)
|
||||
{
|
||||
case LIT_CHAR_DOUBLE_QUOTE:
|
||||
@@ -177,8 +183,7 @@ ecma_builtin_json_parse_string (ecma_json_token_t *token_p) /**< token argument
|
||||
case LIT_CHAR_LOWERCASE_U:
|
||||
{
|
||||
ecma_char_t code_unit;
|
||||
|
||||
if (!(lit_read_code_unit_from_hex (current_p + 1, 4, &code_unit)))
|
||||
if ((end_p - current_p >= 2) && !(lit_read_code_unit_from_hex (current_p + 1, 4, &code_unit)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright JS Foundation and other contributors, http://js.foundation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
JSON.parse('"' + '\\');
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright JS Foundation and other contributors, http://js.foundation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
JSON.parse('"' + '\\u');
|
||||
Reference in New Issue
Block a user