Commit 8e9ae5d
committed
gh-155985: Do not fuse a set difference under IGNORECASE with LOCALE
_fuse_difference() rewrites <flat charset A> (?<![B]) into the single
charset [NEGATE] B [NEGATE] A. That is sound where the engine walks a
set once, but SRE(charset_loc_ignore) walks it twice, once with the
lowercased character and once with the uppercased one, and matches if
either walk does. The second walk starts with the NEGATE polarity
reset, so a character that matches B in one case and A in the other
escapes the subtraction.
The pass did not see the compile flags, so it could not tell the two
apart. Thread the effective flags through optimize() and _walk(),
combining them for a scoped group, and skip the fusion when IGNORECASE
and LOCALE are both set, the condition _compiler.py already uses to
emit IN_LOC_IGNORE.1 parent a7bb524 commit 8e9ae5d
3 files changed
Lines changed: 28 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
467 | 467 | | |
468 | 468 | | |
469 | 469 | | |
470 | | - | |
| 470 | + | |
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
| 474 | + | |
| 475 | + | |
474 | 476 | | |
475 | 477 | | |
476 | 478 | | |
| |||
493 | 495 | | |
494 | 496 | | |
495 | 497 | | |
496 | | - | |
| 498 | + | |
497 | 499 | | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
498 | 503 | | |
499 | | - | |
| 504 | + | |
500 | 505 | | |
501 | 506 | | |
502 | 507 | | |
503 | 508 | | |
504 | | - | |
| 509 | + | |
505 | 510 | | |
506 | | - | |
| 511 | + | |
507 | 512 | | |
508 | | - | |
| 513 | + | |
509 | 514 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1558 | 1558 | | |
1559 | 1559 | | |
1560 | 1560 | | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
1561 | 1577 | | |
1562 | 1578 | | |
1563 | 1579 | | |
| |||
0 commit comments