2 # (c) Petr Baudis <pasky@suse.cz>
16 $cgi->charset('UTF-8');
18 my $pname = to_utf8
($cgi->param('p'), 1);
19 my $ctags = to_utf8
($cgi->param('t'), 1);
20 defined $pname or $pname = '';
21 defined $ctags or $ctags = '';
24 if ($cgi->request_method ne 'POST' || $pname eq '') {
25 print $cgi->header(-status
=>403);
26 print "<p>Invalid data. Go away, sorcerer.</p>\n";
30 if (my $romsg=check_readonly
(1)) {
31 print $cgi->header(-status
=>403);
32 print "<p>$romsg</p>\n";
36 my $proj = Girocco
::Project
::does_exist
($pname, 1) && Girocco
::Project
->load($pname);
38 print $cgi->header(-status
=>404);
39 print "<p>Project \"".html_esc
($pname)."\" does not exist.</p>";
43 my $refproj = $ENV{'HTTP_REFERER'};
44 defined($refproj) or $refproj = "";
45 $refproj = url_path
($refproj);
46 $refproj =~ s{^/w/}{/};
47 my $projurl = url_path
($Girocco::Config
::gitweburl
, 1) . $pname . ".git";
48 $projurl =~ s{^/w/}{/};
49 if ($refproj ne $projurl) {
50 print $cgi->header(-status
=>403);
51 print "<p>Invalid request. Go away, sorcerer.</p>\n";
55 if ($ctags =~ /[^ a-zA-Z0-9:.+#_-]/) {
56 print $cgi->header(-status
=>403);
57 print "<p>Content tag(s) '".html_esc
($ctags)."' contain evil characters.</p>";
61 my $oldmask = umask();
62 umask($oldmask & ~0060);
64 foreach my $ctag (split(/ /, $ctags)) {
65 $changed = 1 if $proj->add_ctag($ctag, 1);
69 $proj->_set_forkchange;
73 print $cgi->header(-status
=>303, -location
=>"@{[url_path($Girocco::Config::gitweburl)]}/$pname.git");