diff options
author | bptato <nincsnevem662@gmail.com> | 2024-02-11 18:04:50 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-02-11 18:38:15 +0100 |
commit | 7f974324de185e5f8e6a8b5723ac70fa8beea47f (patch) | |
tree | 6eb6043f04732b507cbe8b9896aed6b594d35072 /bonus | |
parent | 1d97cd35ba0848ced58732fe430fa0db018701e5 (diff) | |
download | chawan-7f974324de185e5f8e6a8b5723ac70fa8beea47f.tar.gz |
magnet.cgi: use urldec from libexec dir
Diffstat (limited to 'bonus')
-rwxr-xr-x | bonus/magnet.cgi | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/bonus/magnet.cgi b/bonus/magnet.cgi index 085d252b..efff286a 100755 --- a/bonus/magnet.cgi +++ b/bonus/magnet.cgi @@ -23,13 +23,6 @@ die() { exit 1 } -decode() { - # URL-decode the string passed as the first parameter - printf '%s\n' "$1" | \ - sed 's/+/ /g;s/%/\\x/g' | \ - xargs -0 printf "%b" -} - html_quote() { sed 's/&/&/g;s/</</g;s/>/>/g;s/'\''/'/g;s/"/"/g' } @@ -62,16 +55,13 @@ POST) read line esac case $line in URL=*) line="${line#*=}" ;; - *) die 'Invalid POST 2; this is probably a bug in the magnet script.'"$line" ;; + *) die 'Invalid POST 2; this is probably a bug in the magnet script.' ;; esac - line="$(decode "$line")" - if test -n "$CHA_TRANSMISSION_AUTH" - then authparam="--auth=$CHA_TRANSMISSION_AUTH" - fi - if test -n "$authparam" - then output="$(transmission-remote "${CHA_TRANSMISSION_ADDRESS:-localhost:9091}" "$authparam" -a "$line" 2>&1)" - else output="$(transmission-remote "${CHA_TRANSMISSION_ADDRESS:-localhost:9091}" -a "$line" 2>&1)" - fi + line=$(printf '%s' "$line" | "$CHA_LIBEXEC_DIR"/urldec) + auth=$CHA_TRANSMISSION_AUTH + address=${CHA_TRANSMISSION_ADDRESS:-localhost:9091} + output=$(transmission-remote "$address" ${auth:+ --auth="$auth"} \ + -a "$line" 2>&1) printf 'Content-Type: text/plain\n\n%s' "$output" ;; *) die "Unrecognized HTTP method $HTTP_METHOD" ;; |