Skip to content

fix(parser): cap lookahead in looks_like_brace_expansion#1019

Merged
chaliy merged 1 commit intomainfrom
fix/issue-997-brace-lookahead
Apr 2, 2026
Merged

fix(parser): cap lookahead in looks_like_brace_expansion#1019
chaliy merged 1 commit intomainfrom
fix/issue-997-brace-lookahead

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 2, 2026

Summary

  • Cap looks_like_brace_expansion lookahead to 10,000 characters
  • Prevents O(n^2) total scanning when input contains many unmatched { characters

Closes #997

Test plan

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

Closes #997 — looks_like_brace_expansion scanned to end of input for
each unmatched {, causing O(n^2) total scanning on pathological input.
Limits scan to 10,000 characters per invocation.
@chaliy chaliy merged commit fed036d into main Apr 2, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-997-brace-lookahead 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.

Unbounded lookahead in looks_like_brace_expansion causes O(n^2) parsing

1 participant