From 1cd56f7a9021672ead176389d7c94b1a2a730151 Mon Sep 17 00:00:00 2001 From: David Young Date: Sun, 8 Nov 2026 11:36:43 -0700 Subject: [PATCH] report: accept a report ID that ends with a newline Plain-text replies usually end with one, and the ID check counted it as part of the ID, so a report that was sent was said to have failed. Co-Authored-By: Claude Opus 5.5 --- report | 2 ++ tests/report.bats | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/report b/report index fb8bc1c..cf29585 100755 --- a/report +++ b/report @@ -134,6 +134,8 @@ send() { code="${response##*$'\n'}" body="${response%$'\n'*}" [[ "$response" == *$'\n'* ]] || body="$response" + # Without the newline that usually ends a reply + body="${body%"${body##*[![:space:]]}"}" # A 2xx that isn't a report ID is some other page, not the receiver if (( status == 0 )) && [[ "$code" == 2?? && "$body" =~ ^[A-Za-z0-9-]{1,40}$ ]]; then echo "Sent. Thank you! Your report's ID is $body; mention it if you contact us about this." diff --git a/tests/report.bats b/tests/report.bats index 4c8b59c..f59ec7a 100644 --- a/tests/report.bats +++ b/tests/report.bats @@ -147,3 +147,11 @@ field() { [[ "$output" == *"Couldn't send the report"* ]] [[ "$output" != *"Sent."* ]] } + +@test "a report ID ending with a newline, as replies usually do, is accepted" { + answers y + export CURL_REPLY='CD-7Q2K\n\n200' + run bash "$REPO/report" "$LOG" + [ "$status" -eq 0 ] + [[ "$output" == *"Your report's ID is CD-7Q2K;"* ]] +}