Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .agents/scripts/code-audit-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ get_head_sha() {
sql_escape() {
local val
val="$1"
# Replace newlines and carriage returns with spaces to prevent
# multi-line SQL corruption in line-by-line INSERT generation
val="${val//$'\n'/ }"
val="${val//$'\r'/}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency and to correctly handle all types of line endings (like classic Mac OS \r), it's better to replace carriage returns with a space, just like you do for newlines. Currently, \r is removed, which could cause words to be merged together (e.g., word1\rword2 becomes word1word2).

Suggested change
val="${val//$'\r'/}"
val="${val//$'\r'/ }"

val="${val//\'/\'\'}"
echo "$val"
return 0
Expand Down Expand Up @@ -621,6 +625,10 @@ cmd_audit() {
# Auto-detect PR if not specified
if [[ "$pr_number" -eq 0 ]]; then
pr_number=$(gh pr view --json number -q .number 2>/dev/null || echo "0")
if ! [[ "$pr_number" =~ ^[0-9]+$ ]]; then
log_warn "Could not auto-detect PR number, defaulting to 0"
pr_number=0
fi
fi

local head_sha
Expand Down
Loading