Skip to content

fix(webhook): handle special characters in issue title and body - #15

Merged
Lin-Jiong-HDU merged 1 commit into
mainfrom
fix/issue-special-chars-webhook-payload
May 5, 2026
Merged

fix(webhook): handle special characters in issue title and body#15
Lin-Jiong-HDU merged 1 commit into
mainfrom
fix/issue-special-chars-webhook-payload

Conversation

@Lin-Jiong-HDU

@Lin-Jiong-HDU Lin-Jiong-HDU commented May 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Root cause: GitHub Actions workflow 用 curl -d '...' 单引号包裹 JSON payload,当 issue 标题或正文包含单引号(如 It's a bug)时,shell 引号配对被打破,导致 webhook 发送失败
  • 使用 jq --arg + 环境变量安全构造 JSON payload,彻底避免 shell 引号问题
  • 限制 envsubst 只扩展模板中已知的变量名,防止 ${VAR} 意外扩展
  • SanitizeShellValue 中增加 ${ 模式剥离,纵深防御

Changes

File Change
.github/workflows/issue-webhook.yml jq -n --arg 替代手动 JSON 构建
.github/workflows/pr-review-webhook.yml 同上
internal/docker/runner.go SanitizeShellValue 增加 ${ 剥离
runner-image/entrypoint.sh envsubst 指定明确的变量列表

Test plan

  • go vet ./... 通过
  • go build ./... 通过
  • go test ./... 通过
  • golangci-lint run 通过
  • 创建包含单引号/特殊字符的 issue(如 It's a bug (urgent) $100 [claude bot])验证 webhook 正常触发

🤖 Generated with Claude Code

The curl command used single-quoted strings to construct the JSON
payload. When issue titles or bodies contained single quotes (e.g.
"It's a bug"), the shell quoting broke, causing the webhook to fail
silently.

Replace manual JSON construction with jq --arg for safe string handling.
Also restrict envsubst to only expand known template variables, and
strip ${ patterns in SanitizeShellValue for defense in depth.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Lin-Jiong-HDU
Lin-Jiong-HDU merged commit 61bd284 into main May 5, 2026
1 check passed
@Lin-Jiong-HDU
Lin-Jiong-HDU deleted the fix/issue-special-chars-webhook-payload branch May 5, 2026 07:33
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.

1 participant