about summary refs log tree commit diff stats
path: root/bonus
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-02-11 18:04:50 +0100
committerbptato <nincsnevem662@gmail.com>2024-02-11 18:38:15 +0100
commit7f974324de185e5f8e6a8b5723ac70fa8beea47f (patch)
tree6eb6043f04732b507cbe8b9896aed6b594d35072 /bonus
parent1d97cd35ba0848ced58732fe430fa0db018701e5 (diff)
downloadchawan-7f974324de185e5f8e6a8b5723ac70fa8beea47f.tar.gz
magnet.cgi: use urldec from libexec dir
Diffstat (limited to 'bonus')
-rwxr-xr-xbonus/magnet.cgi22
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/&/&amp;/g;s/</&lt;/g;s/>/&gt;/g;s/'\''/&apos;/g;s/"/&quot;/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" ;;
>
37d53a70 ^
5a2cb154 ^
37d53a70 ^


5a2cb154 ^
37d53a70 ^

5a2cb154 ^

37d53a70 ^



5a2cb154 ^
37d53a70 ^
5a2cb154 ^
37d53a70 ^

5a2cb154 ^
37d53a70 ^
5a2cb154 ^
37d53a70 ^

5a2cb154 ^
37d53a70 ^
5a2cb154 ^
37d53a70 ^




608a7fa8 ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115