From a504fd0333e11459497735f3cef5362ef5eeb575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Lang=C3=B3?= Date: Mon, 22 May 2017 13:01:22 +0200 Subject: [PATCH] Fix character escape in character class parsing of RegExp objects. (#1834) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #1830 JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com --- jerry-core/parser/regexp/re-parser.c | 4 ++-- tests/jerry/regression-test-issue-1830.js | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 tests/jerry/regression-test-issue-1830.js diff --git a/jerry-core/parser/regexp/re-parser.c b/jerry-core/parser/regexp/re-parser.c index 10b0da638..d510c6364 100644 --- a/jerry-core/parser/regexp/re-parser.c +++ b/jerry-core/parser/regexp/re-parser.c @@ -363,7 +363,7 @@ re_parse_char_class (re_parser_ctx_t *parser_ctx_p, /**< number of classes */ return ecma_raise_syntax_error (ECMA_ERR_MSG ("invalid character class, end of string after '\\'")); } - ch = *parser_ctx_p->input_curr_p++; + ch = lit_utf8_read_next (&parser_ctx_p->input_curr_p); if (ch == LIT_CHAR_LOWERCASE_B) { @@ -503,7 +503,7 @@ re_parse_char_class (re_parser_ctx_t *parser_ctx_p, /**< number of classes */ else if (lit_char_is_octal_digit ((ecma_char_t) ch) && ch != LIT_CHAR_0) { - parser_ctx_p->input_curr_p--; + lit_utf8_decr (&parser_ctx_p->input_curr_p); ch = (ecma_char_t) re_parse_octal (parser_ctx_p); } } /* ch == LIT_CHAR_BACKSLASH */ diff --git a/tests/jerry/regression-test-issue-1830.js b/tests/jerry/regression-test-issue-1830.js new file mode 100644 index 000000000..23a1e797e --- /dev/null +++ b/tests/jerry/regression-test-issue-1830.js @@ -0,0 +1,17 @@ +// 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. + +/[\꧿]ౘ/ + +var r = new RegExp ("[\꧿]ౘ");