Skip to content

fix(parser): enforce subst depth limit in unquoted cmdsub#1018

Merged
chaliy merged 1 commit intomainfrom
fix/issue-996-read-word-depth
Apr 2, 2026
Merged

fix(parser): enforce subst depth limit in unquoted cmdsub#1018
chaliy merged 1 commit intomainfrom
fix/issue-996-read-word-depth

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 2, 2026

Summary

  • Enforce max_subst_depth in unquoted $() context in read_word, matching the limit already enforced in double-quoted strings
  • Defense-in-depth: prevents deeply nested $() from bypassing depth limit

Closes #996

Test plan

  • New spec tests: cmdsub_depth_unquoted.test.sh with 3 cases
  • Existing parse_incomplete_command_sub test still passes
  • cargo test --all-features passes
  • cargo clippy -- -D warnings clean

Closes #996 — read_word used simple parenthesis counting for $() in
unquoted context, bypassing the max_subst_depth limit that was enforced
in double-quoted strings. Now tracks $( nesting depth and stops
recursing deeper when the limit is reached.
@chaliy chaliy merged commit 21bed02 into main Apr 2, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-996-read-word-depth 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.

Lexer read_word lacks depth tracking for nested $() in unquoted context

1 participant