Skip to content

Commit 21e17a1

Browse files
dbatyairerobika
authored andcommitted
Fix null escape in character classes (#3192)
Fixes #3001. JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
1 parent 5ed8647 commit 21e17a1

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

jerry-core/parser/regexp/re-compiler.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,7 @@ re_parse_char_class (re_compiler_ctx_t *re_ctx_p, /**< number of classes */
452452
re_append_char_class (re_ctx_p, LIT_CHAR_LOWERCASE_Z + 1, LIT_UTF16_CODE_UNIT_MAX);
453453
ch = LIT_CHAR_UNDEF;
454454
}
455-
else if (lit_char_is_octal_digit ((ecma_char_t) ch)
456-
&& ch != LIT_CHAR_0)
455+
else if (lit_char_is_octal_digit ((ecma_char_t) ch))
457456
{
458457
lit_utf8_decr (&parser_ctx_p->input_curr_p);
459458
ch = (ecma_char_t) re_parse_octal (parser_ctx_p);

tests/jerry/regexp-character-class.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,10 @@ assert (r == "abcdefghjklmnopqrstuvwxyz");
133133
r = new RegExp("[\\u0800-\\uffff]", "g");
134134
assert (r.test ("\uffff"));
135135
assert (!r.test ("\uffff"));
136+
137+
r = new RegExp("[\0]");
138+
assert (r.test ("\0"));
139+
assert (!r.test ("0"));
140+
141+
r = new RegExp("[\0-\1]");
142+
assert (r.test ("\1"));

0 commit comments

Comments
 (0)