\n" .
"
blob:" .
- $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name")}, $hash_parent) .
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name")}, $hash_parent) .
" -> blob:" .
- $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, $hash) .
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, $hash) .
"
\n";
git_diff_print($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash);
print "
";
@@ -1872,18 +1944,23 @@ sub git_commitdiff {
if ($hash =~ m/^[0-9a-fA-F]{40}$/) {
$expires = "+1d";
}
+ my $refs = read_info_ref();
+ my $ref = "";
+ if (defined $refs->{$hash}) {
+ $ref = "
\n" .
- $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$hash")}, "shortlog") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$hash")}, "log") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash")}, "commit") .
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$hash")}, "shortlog") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$hash")}, "log") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash")}, "commit") .
" | commitdiff" .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "
\n";
- print $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . "\n" .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "
\n";
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . "\n" .
"
\n" .
- $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, escapeHTML($co{'title'})) . "\n" .
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'}) . $ref) . "\n" .
"
\n";
my $comment = $co{'comment'};
@@ -1919,23 +1996,23 @@ sub git_commitdiff {
my $from_id = $3;
my $to_id = $4;
my $status = $5;
- my $file = $6;
+ my $file = validate_input(unquote($6));
if ($status eq "A") {
print "
" . file_type($to_mode) . ":" .
- $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id) . "(new)" .
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id) . "(new)" .
"
\n";
git_diff_print(undef, "/dev/null", $to_id, "b/$file");
} elsif ($status eq "D") {
print "
" . file_type($from_mode) . ":" .
- $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) . "(deleted)" .
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) . "(deleted)" .
"
\n";
git_diff_print($from_id, "a/$file", undef, "/dev/null");
} elsif ($status eq "M") {
if ($from_id ne $to_id) {
print "
" .
- file_type($from_mode) . ":" . $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) .
+ file_type($from_mode) . ":" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) .
" -> " .
- file_type($to_mode) . ":" . $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id);
+ file_type($to_mode) . ":" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id);
print "
\n";
git_diff_print($from_id, "a/$file", $to_id, "b/$file");
}
@@ -1954,23 +2031,18 @@ sub git_commitdiff_plain {
# try to figure out the next tag after this commit
my $tagname;
- my %taghash;
- my $tags = git_read_refs("refs/tags");
- foreach my $entry (@$tags) {
- my %tag = %$entry;
- $taghash{$tag{'refid'}} = $tag{'name'};
- }
+ my $refs = read_info_ref("tags");
open $fd, "-|", "$gitbin/git-rev-list HEAD";
- while (my $commit = <$fd>) {
- chomp $commit;
- if ($taghash{$commit}) {
- $tagname = $taghash{$commit};
+ chomp (my (@commits) = <$fd>);
+ close $fd;
+ foreach my $commit (@commits) {
+ if (defined $refs->{$commit}) {
+ $tagname = $refs->{$commit}
}
if ($commit eq $hash) {
last;
}
}
- close $fd;
print $cgi->header(-type => "text/plain", -charset => 'utf-8', '-content-disposition' => "inline; filename=\"git-$hash.patch\"");
my %co = git_read_commit($hash);
@@ -1986,7 +2058,7 @@ sub git_commitdiff_plain {
"\n";
foreach my $line (@$comment) {;
- print " $line\n";
+ print "$line\n";
}
print "---\n\n";
@@ -2014,20 +2086,21 @@ sub git_history {
if (!%co) {
die_error(undef, "Unknown commit object.");
}
+ my $refs = read_info_ref();
git_header_html();
print "
\n" .
- $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "shortlog") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log")}, "log") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash")}, "commit") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") .
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log")}, "log") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash")}, "commit") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") .
"
\n" .
"
\n";
print "
\n" .
- $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, escapeHTML($co{'title'})) . "\n" .
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" .
"
\n";
- print "
/$file_name
\n";
+ print "
/" . esc_html($file_name) . "
\n";
open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin \'$file_name\'";
my $commit;
@@ -2043,6 +2116,10 @@ sub git_history {
if (!%co) {
next;
}
+ my $ref = "";
+ if (defined $refs->{$commit}) {
+ $ref = "
" . esc_html($refs->{$commit}) . "";
+ }
if ($alternate) {
print "
\n";
} else {
@@ -2050,18 +2127,18 @@ sub git_history {
}
$alternate ^= 1;
print "| $co{'age_string_date'} | \n" .
- "" . escapeHTML(chop_str($co{'author_name'}, 15, 3)) . " | \n" .
- "" . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit"), -class => "list"}, "" .
- escapeHTML(chop_str($co{'title'}, 50)) . "") . " | \n" .
+ "" . esc_html(chop_str($co{'author_name'}, 15, 3)) . " | \n" .
+ "" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, "" .
+ esc_html(chop_str($co{'title'}, 50)) . "$ref") . " | \n" .
"" .
- $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit")}, "commit") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=blob;hb=$commit;f=$file_name")}, "blob");
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;hb=$commit;f=$file_name")}, "blob");
my $blob = git_get_hash_by_path($hash, $file_name);
my $blob_parent = git_get_hash_by_path($commit, $file_name);
if (defined $blob && defined $blob_parent && $blob ne $blob_parent) {
print " | " .
- $cgi->a({-href => esc("$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name")},
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name")},
"diff to current");
}
print " | \n" .
@@ -2101,17 +2178,17 @@ sub git_search {
}
git_header_html();
print "\n" .
- $cgi->a({-href => esc("$my_uri?p=$project;a=summary;h=$hash")}, "summary") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "shortlog") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$hash")}, "log") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash")}, "commit") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") .
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary;h=$hash")}, "summary") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$hash")}, "log") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash")}, "commit") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") .
"
\n" .
"
\n";
print "\n" .
- $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, escapeHTML($co{'title'})) . "\n" .
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" .
"
\n";
print "\n";
my $alternate = 0;
@@ -2140,16 +2217,16 @@ sub git_search {
}
$alternate ^= 1;
print "| $co{'age_string_date'} | \n" .
- "" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . " | \n" .
+ "" . esc_html(chop_str($co{'author_name'}, 15, 5)) . " | \n" .
"" .
- $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "" . escapeHTML(chop_str($co{'title'}, 50)) . " ");
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "" . esc_html(chop_str($co{'title'}, 50)) . " ");
my $comment = $co{'comment'};
foreach my $line (@$comment) {
if ($line =~ m/^(.*)($searchtext)(.*)$/i) {
- my $lead = escapeHTML($1) || "";
+ my $lead = esc_html($1) || "";
$lead = chop_str($lead, 30, 10);
- my $match = escapeHTML($2) || "";
- my $trail = escapeHTML($3) || "";
+ my $match = esc_html($2) || "";
+ my $trail = esc_html($3) || "";
$trail = chop_str($trail, 30, 10);
my $text = "$lead$match$trail";
print chop_str($text, 80, 5) . " \n";
@@ -2157,8 +2234,8 @@ sub git_search {
}
print " | \n" .
"" .
- $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$co{'id'}")}, "commit") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree");
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$co{'id'}")}, "commit") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree");
print " | \n" .
"\n";
}
@@ -2193,20 +2270,20 @@ sub git_search {
}
$alternate ^= 1;
print "$co{'age_string_date'} | \n" .
- "" . escapeHTML(chop_str($co{'author_name'}, 15, 5)) . " | \n" .
+ "" . esc_html(chop_str($co{'author_name'}, 15, 5)) . " | \n" .
"" .
- $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "" .
- escapeHTML(chop_str($co{'title'}, 50)) . " ");
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "" .
+ esc_html(chop_str($co{'title'}, 50)) . " ");
while (my $setref = shift @files) {
my %set = %$setref;
- print $cgi->a({-href => esc("$my_uri?p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}"), class => "list"},
- "" . escapeHTML($set{'file'}) . "") .
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}"), class => "list"},
+ "" . esc_html($set{'file'}) . "") .
" \n";
}
print " | \n" .
"" .
- $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$co{'id'}")}, "commit") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree");
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$co{'id'}")}, "commit") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree");
print " | \n" .
"\n";
}
@@ -2227,14 +2304,15 @@ sub git_shortlog {
if (!defined $page) {
$page = 0;
}
+ my $refs = read_info_ref();
git_header_html();
print "\n" .
- $cgi->a({-href => esc("$my_uri?p=$project;a=summary")}, "summary") .
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
" | shortlog" .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=log;h=$hash")}, "log") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$hash")}, "commit") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "
\n";
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$hash")}, "log") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash")}, "commit") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "
\n";
my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed.");
@@ -2242,31 +2320,35 @@ sub git_shortlog {
close $fd;
if ($hash ne $head || $page) {
- print $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog")}, "HEAD");
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "HEAD");
} else {
print "HEAD";
}
if ($page > 0) {
print " ⋅ " .
- $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page-1)), -accesskey => "p", -title => "Alt-p"}, "prev");
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$hash;pg=" . ($page-1)), -accesskey => "p", -title => "Alt-p"}, "prev");
} else {
print " ⋅ prev";
}
if ($#revlist >= (100 * ($page+1)-1)) {
print " ⋅ " .
- $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -accesskey => "n", -title => "Alt-n"}, "next");
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -accesskey => "n", -title => "Alt-n"}, "next");
} else {
print " ⋅ next";
}
print "
\n" .
"
\n";
print "\n" .
- $cgi->a({-href => esc("$my_uri?p=$project;a=summary"), -class => "title"}, " ") .
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary"), -class => "title"}, " ") .
"
\n";
print "\n";
my $alternate = 0;
for (my $i = ($page * 100); $i <= $#revlist; $i++) {
my $commit = $revlist[$i];
+ my $ref = "";
+ if (defined $refs->{$commit}) {
+ $ref = " " . esc_html($refs->{$commit}) . "";
+ }
my %co = git_read_commit($commit);
my %ad = date_str($co{'author_epoch'});
if ($alternate) {
@@ -2276,26 +2358,26 @@ sub git_shortlog {
}
$alternate ^= 1;
print "| $co{'age_string_date'} | \n" .
- "" . escapeHTML(chop_str($co{'author_name'}, 10)) . " | \n" .
+ "" . esc_html(chop_str($co{'author_name'}, 10)) . " | \n" .
"";
if (length($co{'title_short'}) < length($co{'title'})) {
- print $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"},
- "" . escapeHTML($co{'title_short'}) . "");
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"},
+ "" . esc_html($co{'title_short'}) . "$ref");
} else {
- print $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit"), -class => "list"},
- "" . escapeHTML($co{'title_short'}) . "");
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"},
+ "" . esc_html($co{'title_short'}) . "$ref");
}
print " | \n" .
"" .
- $cgi->a({-href => esc("$my_uri?p=$project;a=commit;h=$commit")}, "commit") .
- " | " . $cgi->a({-href => esc("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") .
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
" | \n" .
"";
}
if ($#revlist >= (100 * ($page+1)-1)) {
print "\n" .
"| " .
- $cgi->a({-href => esc("$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -title => "Alt-n"}, "next") .
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -title => "Alt-n"}, "next") .
" | \n" .
"
\n";
}