From ce1d5552884040072d3b98af2bb44552a876ae00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Lang=C3=B3?= Date: Wed, 19 Jul 2017 11:01:16 +0200 Subject: [PATCH] Fix regression after #1927 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com --- jerry-core/parser/regexp/re-parser.c | 40 ++++++++------------------- tests/jerry/regexp-character-class.js | 4 +++ 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/jerry-core/parser/regexp/re-parser.c b/jerry-core/parser/regexp/re-parser.c index 8e028e7d5..de050a7ee 100644 --- a/jerry-core/parser/regexp/re-parser.c +++ b/jerry-core/parser/regexp/re-parser.c @@ -518,49 +518,31 @@ re_parse_char_class (re_parser_ctx_t *parser_ctx_p, /**< number of classes */ } } /* ch == LIT_CHAR_BACKSLASH */ - if (ch == LIT_CHAR_UNDEF) + if (start != LIT_CHAR_UNDEF) { - if (start != LIT_CHAR_UNDEF) + if (is_range) { - if (is_range) + if (start > ch) { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("invalid character class, invalid range")); + return ecma_raise_syntax_error (ECMA_ERR_MSG ("invalid character class, wrong order")); } else { - append_char_class (re_ctx_p, start, start); + append_char_class (re_ctx_p, start, ch); start = LIT_CHAR_UNDEF; - } - } - } - else - { - if (start != LIT_CHAR_UNDEF) - { - if (is_range) - { - if (start > ch) - { - return ecma_raise_syntax_error (ECMA_ERR_MSG ("invalid character class, wrong order")); - } - else - { - append_char_class (re_ctx_p, start, ch); - start = LIT_CHAR_UNDEF; - is_range = false; - } - } - else - { - append_char_class (re_ctx_p, start, start); - start = ch; + is_range = false; } } else { + append_char_class (re_ctx_p, start, start); start = ch; } } + else + { + start = ch; + } } while (token_type == RE_TOK_START_CHAR_CLASS || token_type == RE_TOK_START_INV_CHAR_CLASS); diff --git a/tests/jerry/regexp-character-class.js b/tests/jerry/regexp-character-class.js index baa897a30..d08131cef 100644 --- a/tests/jerry/regexp-character-class.js +++ b/tests/jerry/regexp-character-class.js @@ -129,3 +129,7 @@ assert (r == "abcdefghjklmnopqrstuvwxyz"); r = new RegExp ("[\\x61-\\x7a]+$").exec("abcdefghjklmnopqrstuvwxyz"); assert (r == "abcdefghjklmnopqrstuvwxyz"); + +r = new RegExp("[\\u0800-\\uffff]", "g"); +assert (r.test ("\uffff")); +assert (!r.test ("\uffff"));