l fysiirc: strip newlines harder

This commit is contained in:
lassulus 2022-03-28 17:27:03 +02:00
parent ae9c0b1271
commit b9e0a7ec71

View File

@ -54,14 +54,20 @@ in {
name = "reaktor2-fysiweb-github"; name = "reaktor2-fysiweb-github";
}; };
script = ''. ${pkgs.writeDash "github-irc" '' script = ''. ${pkgs.writeDash "github-irc" ''
set -efu set -xefu
case "$Method $Request_URI" in case "$Method $Request_URI" in
"POST /") "POST /")
payload=$(head -c "$req_content_length" \ payload=$(head -c "$req_content_length")
| sed 's/+/ /g;s/%\(..\)/\\x\1/g;' \ echo "$payload" >&2
| xargs -0 echo -e \ payload2=$payload
) payload2=$(echo "$payload" | tr '\n' ' ' | tr -d '\r')
echo "$payload" | ${format-github-message}/bin/format-github-message if [ "$payload" != "$payload2" ]; then
echo "payload has been mangled" >&2
else
echo "payload not mangled" >&2
fi
echo "$payload2" > /tmp/last_fysi_payload
echo "$payload2" | ${format-github-message}/bin/format-github-message
printf 'HTTP/1.1 200 OK\r\n' printf 'HTTP/1.1 200 OK\r\n'
printf 'Connection: close\r\n' printf 'Connection: close\r\n'
printf '\r\n' printf '\r\n'