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 <noreply@anthropic.com>
This commit is contained in:
@@ -134,6 +134,8 @@ send() {
|
|||||||
code="${response##*$'\n'}"
|
code="${response##*$'\n'}"
|
||||||
body="${response%$'\n'*}"
|
body="${response%$'\n'*}"
|
||||||
[[ "$response" == *$'\n'* ]] || body="$response"
|
[[ "$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
|
# 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
|
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."
|
echo "Sent. Thank you! Your report's ID is $body; mention it if you contact us about this."
|
||||||
|
|||||||
@@ -147,3 +147,11 @@ field() {
|
|||||||
[[ "$output" == *"Couldn't send the report"* ]]
|
[[ "$output" == *"Couldn't send the report"* ]]
|
||||||
[[ "$output" != *"Sent."* ]]
|
[[ "$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;"* ]]
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user