From 21e17a14128b682795c2c2a546c6b9aa65ff5460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20B=C3=A1tyai?= Date: Thu, 3 Oct 2019 09:28:00 +0200 Subject: [PATCH] Fix null escape in character classes (#3192) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #3001. JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu --- jerry-core/parser/regexp/re-compiler.c | 3 +-- tests/jerry/regexp-character-class.js | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/jerry-core/parser/regexp/re-compiler.c b/jerry-core/parser/regexp/re-compiler.c index 971da567c..45f89c519 100644 --- a/jerry-core/parser/regexp/re-compiler.c +++ b/jerry-core/parser/regexp/re-compiler.c @@ -452,8 +452,7 @@ re_parse_char_class (re_compiler_ctx_t *re_ctx_p, /**< number of classes */ re_append_char_class (re_ctx_p, LIT_CHAR_LOWERCASE_Z + 1, LIT_UTF16_CODE_UNIT_MAX); ch = LIT_CHAR_UNDEF; } - else if (lit_char_is_octal_digit ((ecma_char_t) ch) - && ch != LIT_CHAR_0) + else if (lit_char_is_octal_digit ((ecma_char_t) ch)) { lit_utf8_decr (&parser_ctx_p->input_curr_p); ch = (ecma_char_t) re_parse_octal (parser_ctx_p); diff --git a/tests/jerry/regexp-character-class.js b/tests/jerry/regexp-character-class.js index d08131cef..88208ec0b 100644 --- a/tests/jerry/regexp-character-class.js +++ b/tests/jerry/regexp-character-class.js @@ -133,3 +133,10 @@ assert (r == "abcdefghjklmnopqrstuvwxyz"); r = new RegExp("[\\u0800-\\uffff]", "g"); assert (r.test ("\uffff")); assert (!r.test ("\uffff")); + +r = new RegExp("[\0]"); +assert (r.test ("\0")); +assert (!r.test ("0")); + +r = new RegExp("[\0-\1]"); +assert (r.test ("\1"));