Fix infinite loop on zero-length regex matches #8

Closed
ocavue wants to merge 1 commit from ocavue/prosemirror-search:ocavue-fix-re into main
First-time contributor

Patches buildMatchDeco and replaceAll all handle zero-length regex like .? and .*.

How to test:

Without patch:

$ npm run prepare && NODE_OPTIONS="--max-old-space-size=512" npm run test
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

With patch:

$ npm run prepare && NODE_OPTIONS="--max-old-space-size=512" npm run test
  48 passing (15ms)
Patches `buildMatchDeco` and `replaceAll` all handle zero-length regex like `.?` and `.*`. How to test: Without patch: ``` $ npm run prepare && NODE_OPTIONS="--max-old-space-size=512" npm run test FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory ----- Native stack trace ----- ``` With patch: ``` $ npm run prepare && NODE_OPTIONS="--max-old-space-size=512" npm run test 48 passing (15ms) ```
Owner

Thanks. Merged as 23525601a0, tweaked in a81de6e161 and 57204875a9

Thanks. Merged as 23525601a0391d, tweaked in a81de6e161b841 and 57204875a99c7
marijn closed this pull request 2026-05-16 13:36:21 +02:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
prosemirror/prosemirror-search!8
No description provided.