Skip to content

fix(Foundation): Fix incorrect bitwise check for newline mode in RegularExpression #4870#5088

Merged
matejk merged 1 commit intomainfrom
fix/4870-regex-newline-bitwise-check
Dec 16, 2025
Merged

fix(Foundation): Fix incorrect bitwise check for newline mode in RegularExpression #4870#5088
matejk merged 1 commit intomainfrom
fix/4870-regex-newline-bitwise-check

Conversation

@matejk
Copy link
Copy Markdown
Contributor

@matejk matejk commented Dec 15, 2025

Summary

  • Fixed incorrect bitwise checks when determining newline mode in RegularExpression.cpp
  • The newline mode flags (RE_NEWLINE_LF, RE_NEWLINE_CRLF, RE_NEWLINE_ANY, RE_NEWLINE_ANYCRLF) are encoded values in a 4-bit field, not independent bit flags
  • The previous code used simple bitwise AND checks which failed when certain flag combinations shared bits (e.g., RE_NEWLINE_ANYCRLF (0x00500000) incorrectly matched RE_NEWLINE_CRLF (0x00300000) because 0x00500000 & 0x00300000 != 0)
  • Added testSubst5 test case that reproduces the issue from Foundation: Incorrect bitwise check for newline mode in RegularExpression #4870

Test plan

  • Built Foundation library with minimal build configuration
  • Ran RegularExpressionTest suite - all 18 tests pass including new testSubst5
  • CI should verify on all platforms

Closes #4870

@matejk matejk merged commit edd5822 into main Dec 16, 2025
80 checks passed
@matejk matejk deleted the fix/4870-regex-newline-bitwise-check branch December 16, 2025 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Foundation: Incorrect bitwise check for newline mode in RegularExpression

1 participant