Skip to content

Commit 542cb11

Browse files
committed
Fix incorrect class character matches in JIT
1 parent 92d56a1 commit 542cb11

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ lookahead assertions are now ignored if the immediately following item is one
195195
that sets a mandatory starting character. For example, /a?(?=bc|)d/ used to set
196196
all of a, b, and d as possible starting code units; now it sets only a and d.
197197

198+
54. Fix incorrect class character matches in JIT.
199+
198200

199201
Version 10.42 11-December-2022
200202
------------------------------

src/pcre2_jit_compile.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8252,6 +8252,7 @@ while (*cc != XCL_END)
82528252
OP2U(SLJIT_AND | SLJIT_SET_Z, typereg, 0, SLJIT_IMM, UCPCAT(ucp_Cf));
82538253
jump = JUMP(SLJIT_ZERO);
82548254

8255+
c = charoffset;
82558256
/* In case of ucp_Cf, we overwrite the result. */
82568257
SET_CHAR_OFFSET(0x2066);
82578258
OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, 0x2069 - 0x2066);
@@ -8263,6 +8264,9 @@ while (*cc != XCL_END)
82638264
OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, 0x180e - 0x2066);
82648265
OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL);
82658266

8267+
/* Restore charoffset. */
8268+
SET_CHAR_OFFSET(c);
8269+
82668270
JUMPHERE(jump);
82678271
jump = CMP(SLJIT_ZERO ^ invertcmp, TMP2, 0, SLJIT_IMM, 0);
82688272
break;
@@ -8274,6 +8278,7 @@ while (*cc != XCL_END)
82748278
OP2U(SLJIT_AND | SLJIT_SET_Z, typereg, 0, SLJIT_IMM, UCPCAT(ucp_Cf));
82758279
jump = JUMP(SLJIT_ZERO);
82768280

8281+
c = charoffset;
82778282
/* In case of ucp_Cf, we overwrite the result. */
82788283
SET_CHAR_OFFSET(0x2066);
82798284
OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, 0x2069 - 0x2066);
@@ -8282,6 +8287,9 @@ while (*cc != XCL_END)
82828287
OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP1, 0, SLJIT_IMM, 0x061c - 0x2066);
82838288
OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_EQUAL);
82848289

8290+
/* Restore charoffset. */
8291+
SET_CHAR_OFFSET(c);
8292+
82858293
JUMPHERE(jump);
82868294
jump = CMP(SLJIT_ZERO ^ invertcmp, TMP2, 0, SLJIT_IMM, 0);
82878295
break;
@@ -8326,7 +8334,7 @@ while (*cc != XCL_END)
83268334
OP2U(SLJIT_SUB | SLJIT_SET_LESS_EQUAL, TMP1, 0, SLJIT_IMM, 0xff46 - 0xff41);
83278335
OP_FLAGS(SLJIT_OR, TMP2, 0, SLJIT_LESS_EQUAL);
83288336

8329-
SET_CHAR_OFFSET(CHAR_a);
8337+
SET_CHAR_OFFSET(0xff10);
83308338

83318339
JUMPHERE(jump);
83328340
OP2U(SLJIT_SUB | SLJIT_SET_Z, TMP2, 0, SLJIT_IMM, 0);

src/pcre2_jit_test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ static struct regression_test_case regression_test_cases[] = {
421421
{ MUP, 0, 0, 0, "[\\p{Lu}\\P{Latin}]+", "c\xEA\xA4\xAE,A,b" },
422422
{ MUP, 0, 0, 0, "[\\x{a92e}\\p{Lu}\\P{Latin}]+", "c\xEA\xA4\xAE,A,b" },
423423
{ CMUP, 0, 0, 0, "[^S]\\B", "\xe2\x80\x8a" },
424+
{ MUP, 0, 0, 0 | F_NOMATCH, "[^[:print:]\\x{f6f6}]", "\xef\x9b\xb6" },
425+
{ MUP, 0, 0, 0, "[[:xdigit:]\\x{6500}]#", "\xe6\x94\x80#" },
424426

425427
/* Possible empty brackets. */
426428
{ MU, A, 0, 0, "(?:|ab||bc|a)+d", "abcxabcabd" },

0 commit comments

Comments
 (0)