Skip to content

fix: strip heredoc body before pipe/chain checks (#21)#23

Merged
josephfung merged 1 commit into
mainfrom
fix/heredoc-pipe-false-positive
Apr 26, 2026
Merged

fix: strip heredoc body before pipe/chain checks (#21)#23
josephfung merged 1 commit into
mainfrom
fix/heredoc-pipe-false-positive

Conversation

@josephfung
Copy link
Copy Markdown
Owner

Summary

  • | characters inside a <<'EOF' heredoc body were surviving the quote-stripping pass and being misidentified as pipe operators
  • Commands like gh issue create --body "$(cat <<'EOF' ... | table | ... EOF )" were incorrectly blocked whenever the body contained markdown tables, option lists, or type unions
  • Fix: after quote-stripping, if the stripped command contains a heredoc opener (<<), keep only the first line for chaining analysis — the heredoc body is literal text and cannot contain shell operators

Test plan

  • bash hooks/no-chaining.test.sh — 49 tests, all pass
  • New tests cover the three false-positive cases from issue fix: no-chaining hook false-positive on | inside heredoc body #21: option-list |, markdown table |, type-union |
  • New tests confirm real pipes on the heredoc opener line are still caught (safe pipe allowed, unsafe pipe blocked)

Closes #21

@josephfung
Copy link
Copy Markdown
Owner Author

@coderabbitai can you please review?

Repository owner deleted a comment from coderabbitai Bot Apr 25, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 25, 2026

@josephfung: Ah yes, another review. What a thrilling way to spend eternity. I'll cast my considerable intellect — brain the size of a planet, naturally — over your heredoc pipe-stripping fix momentarily.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Repository owner deleted a comment from coderabbitai Bot Apr 26, 2026
…ives

Literal | characters inside a <<'EOF' heredoc body were surviving the
quote-stripping pass and being misidentified as pipe operators. This caused
commands like `gh issue create --body "$(cat <<'EOF' ... EOF )"` to be
incorrectly blocked whenever the body contained markdown tables, option
lists, or type unions with | in them.

Fix: after quote-stripping, if the stripped command contains a heredoc
opener (<<), keep only the first line for chaining analysis. The heredoc
body is literal text and cannot contain shell operators.

Closes #21
@josephfung josephfung force-pushed the fix/heredoc-pipe-false-positive branch from 312d5e8 to 9fa4c5b Compare April 26, 2026 02:06
Repository owner deleted a comment from coderabbitai Bot Apr 26, 2026
Repository owner deleted a comment from coderabbitai Bot Apr 26, 2026
@josephfung josephfung merged commit 9ba7f89 into main Apr 26, 2026
2 checks passed
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.

fix: no-chaining hook false-positive on | inside heredoc body

1 participant