]> git.plutz.net Git - busy/blob - write/projectmeta.cgi
prevent endless loop on malformed svn path
[busy] / write / projectmeta.cgi
1 #!/bin/zsh
2
3 # Copyright 2012 Paul Hänsch
4 # This file is part of Busy
5 #
6 # Busy is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Busy is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU Affero General Public License for more details.
15 #
16 # You should have received a copy of the GNU Affero General Public License
17 # along with Busy.  If not, see <http://www.gnu.org/licenses/>.
18
19 metafile="../project.meta"
20
21 [ "$HTTPS" = "on" ] && proto=https || proto=http
22 . ../auth/permissions.sh
23 $ACL_ADMIN || echo "Location: ${proto}://${HTTP_HOST}/?p=Error&i=noaccess\n\n"
24 $ACL_ADMIN || exit 0 
25
26 if [ -n "${CONTENT_LENGTH}" -a "${CONTENT_LENGTH}" -gt 0 ]; then
27 (head -c "${CONTENT_LENGTH}"; echo)|sed 's/&/\n/g' \
28   |sed -rn '/^((appName|appSlogan|svnRepo|gitRepo|flattrThingURL|paypalAddress|btcAddress|btcAdAddress)=.*|repoType=(svn|git)|(useFlattr|usePaypal|useBitcoin|btcAdGamble|btcAdErotic)=yes|advertise=(btcAd|no))$/{
29             s:\+: :g;s:%:\\x:g;p}' \
30   |while line="$(line)"; do
31     eval "$(echo -e "$line" |sed -r 's:[\n\r'\'']::g;s:^([a-zA-Z0-9_+-]+)=(.*)$:\1='"'\2'"':;')"
32   done
33 fi
34
35 [ "$btcAdGamble" = yes -a "$btcAdErotic" = yes ] && btcAdContent=1
36 [ "$btcAdGamble" != yes -a "$btcAdErotic" = yes ] && btcAdContent=2
37 [ "$btcAdGamble" = yes -a "$btcAdErotic" != yes ] && btcAdContent=3
38 [ "$btcAdGamble" != yes -a "$btcAdErotic" != yes ] && btcAdContent=4
39
40 echo "\
41 name=$appName
42 slogan=$appSlogan
43 repoType=$repoType
44 svnRepo=$svnRepo
45 gitRepo=$gitRepo
46 useFlattr=$useFlattr
47 flattrThingURL=$flattrThingURL
48 usePaypal=$usePaypal
49 paypalAddress=$paypalAddress
50 useBitcoin=$useBitcoin
51 btcAddress=$btcAddress
52 advertise=$advertise
53 btcAdAddress=$btcAdAddress
54 btcAdContent=$btcAdContent
55 " >"$metafile"
56
57 echo -n "Location: ${proto}://${HTTP_HOST}/?p=Admin\n\n"