Skip to content

fix(interpreter): cap glob_match calls in remove_pattern_glob#1016

Merged
chaliy merged 1 commit intomainfrom
fix/issue-994-glob-match-cap
Apr 2, 2026
Merged

fix(interpreter): cap glob_match calls in remove_pattern_glob#1016
chaliy merged 1 commit intomainfrom
fix/issue-994-glob-match-cap

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 2, 2026

Summary

  • Cap glob_match invocations in remove_pattern_glob to 10,000 to prevent O(n^2) CPU exhaustion
  • Bracket expressions like [a]* on long strings no longer cause quadratic scanning

Closes #994

Test plan

  • New spec tests: glob_match_cap.test.sh with 4 cases
  • cargo test --all-features passes
  • cargo clippy -- -D warnings clean

Closes #994 — remove_pattern_glob called glob_match for every split
point of the input string, causing O(n^2) CPU exhaustion on long strings
with bracket expressions. Caps at 10,000 invocations.
@chaliy chaliy merged commit 524dc54 into main Apr 2, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-994-glob-match-cap branch April 2, 2026 14:53
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.

O(n^2) glob pattern matching in remove_pattern_glob for bracket expressions

1 participant