allow utf8 characters in url parameter escape
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
Kay Sievers committed
Nov 24, 2005 at 16:56 UTC
232ff5536c6d2016e1ac14c3f1c8703b54a69ad8
1 file changed
+222
-206
gitweb.cgi
+222
-206
@@ -80,8 +80,8 @@ if (defined $project) {
80
undef $project;
81
die_error(undef, "No such project.");
82
}
83
- $rss_link = "<link rel=\"alternate\" title=\"" . esc_url($project) . " log\" href=\"" .
84
- esc_url("$my_uri?p=$project;a=rss") . "\" type=\"application/rss+xml\"/>";
83
+ $rss_link = "<link rel=\"alternate\" title=\"" . esc_param($project) . " log\" href=\"" .
84
+ "$my_uri?" . esc_param("p=$project;a=rss") . "\" type=\"application/rss+xml\"/>";
85
$ENV{'GIT_DIR'} = "$projectroot/$project";
86
} else {
87
git_project_list();
@@ -146,7 +146,7 @@ sub validate_input {
146
if ($input =~ m/(^|\/)(|\.|\.\.)($|\/)/) {
147
return undef;
148
}
149
- if ($input =~ m/[^a-zA-Z0-9_ \.\/\-\+\#\~]/) {
149
+ if ($input =~ m/[^a-zA-Z0-9_\x80-\xff\ \.\/\-\+\#\~\%]/) {
150
return undef;
151
}
152
return $input;
@@ -209,13 +209,17 @@ if (!defined $action || $action eq "summary") {
209
exit;
210
}
211
212
-sub esc_url {
212
+# quote unsafe chars, but keep the slash, even when it's not
213
+# correct, but quoted slashes look too horrible in bookmarks
214
+sub esc_param {
215
my $str = shift;
216
+ $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&=])/sprintf("%%%02X", ord($1))/eg;
217
$str =~ s/\+/%2B/g;
218
$str =~ s/ /\+/g;
219
return $str;
220
}
221
222
+# replace invalid utf8 character with SUBSTITUTION sequence
223
sub esc_html {
224
my $str = shift;
225
$str = decode("utf8", $str, Encode::FB_DEFAULT);
@@ -223,6 +227,16 @@ sub esc_html {
227
return $str;
228
}
229
230
+# git may return quoted and escaped filenames
231
+sub unquote {
232
+ my $str = shift;
233
+ if ($str =~ m/^"(.*)"$/) {
234
+ $str = $1;
235
+ $str =~ s/\\([0-7]{1,3})/chr(oct($1))/eg;
236
+ }
237
+ return $str;
238
+}
239
+
240
sub git_header_html {
241
my $status = shift || "200 OK";
242
my $expires = shift;
@@ -303,11 +317,11 @@ a.rss_logo:hover { background-color:#ee5500; }
317
EOF
318
print "<div class=\"page_header\">\n" .
319
"<a href=\"http://www.kernel.org/pub/software/scm/git/docs/\" title=\"git documentation\">" .
306
- "<img src=\"" . esc_url("$my_uri?a=git-logo.png") . "\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" .
320
+ "<img src=\"$my_uri?" . esc_param("a=git-logo.png") . "\" width=\"72\" height=\"27\" alt=\"git\" style=\"float:right; border-width:0px;\"/>" .
321
"</a>\n";
308
- print $cgi->a({-href => esc_url($home_link)}, "projects") . " / ";
322
+ print $cgi->a({-href => esc_param($home_link)}, "projects") . " / ";
323
if (defined $project) {
310
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, esc_html($project));
324
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, esc_html($project));
325
if (defined $action) {
326
print " / $action";
327
}
@@ -342,9 +356,9 @@ sub git_footer_html {
356
if (defined $descr) {
357
print "<div class=\"page_footer_text\">" . esc_html($descr) . "</div>\n";
358
}
345
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=rss"), -class => "rss_logo"}, "RSS") . "\n";
359
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=rss"), -class => "rss_logo"}, "RSS") . "\n";
360
} else {
347
- print $cgi->a({-href => esc_url("$my_uri?a=opml"), -class => "rss_logo"}, "OPML") . "\n";
361
+ print $cgi->a({-href => "$my_uri?" . esc_param("a=opml"), -class => "rss_logo"}, "OPML") . "\n";
362
}
363
print "</div>\n" .
364
"</body>\n" .
@@ -685,7 +699,7 @@ sub format_log_line_html {
699
if ($line =~ m/([0-9a-fA-F]{40})/) {
700
my $hash_text = $1;
701
if (git_get_type($hash_text) eq "commit") {
688
- my $link = $cgi->a({-class => "text", -href => esc_url("$my_uri?p=$project;a=commit;h=$hash_text")}, $hash_text);
702
+ my $link = $cgi->a({-class => "text", -href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_text")}, $hash_text);
703
$line =~ s/$hash_text/$link/;
704
}
705
}
@@ -834,25 +848,25 @@ sub git_project_list {
848
@projects = sort {$a->{'path'} cmp $b->{'path'}} @projects;
849
print "<th>Project</th>\n";
850
} else {
837
- print "<th>" . $cgi->a({-class => "header", -href => esc_url("$my_uri?o=project")}, "Project") . "</th>\n";
851
+ print "<th>" . $cgi->a({-class => "header", -href => "$my_uri?" . esc_param("o=project")}, "Project") . "</th>\n";
852
}
853
if (defined($order) && ($order eq "descr")) {
854
@projects = sort {$a->{'descr'} cmp $b->{'descr'}} @projects;
855
print "<th>Description</th>\n";
856
} else {
843
- print "<th>" . $cgi->a({-class => "header", -href => esc_url("$my_uri?o=descr")}, "Description") . "</th>\n";
857
+ print "<th>" . $cgi->a({-class => "header", -href => "$my_uri?" . esc_param("o=descr")}, "Description") . "</th>\n";
858
}
859
if (defined($order) && ($order eq "owner")) {
860
@projects = sort {$a->{'owner'} cmp $b->{'owner'}} @projects;
861
print "<th>Owner</th>\n";
862
} else {
849
- print "<th>" . $cgi->a({-class => "header", -href => esc_url("$my_uri?o=owner")}, "Owner") . "</th>\n";
863
+ print "<th>" . $cgi->a({-class => "header", -href => "$my_uri?" . esc_param("o=owner")}, "Owner") . "</th>\n";
864
}
865
if (defined($order) && ($order eq "age")) {
866
@projects = sort {$a->{'commit'}{'age'} <=> $b->{'commit'}{'age'}} @projects;
867
print "<th>Last Change</th>\n";
868
} else {
855
- print "<th>" . $cgi->a({-class => "header", -href => esc_url("$my_uri?o=age")}, "Last Change") . "</th>\n";
869
+ print "<th>" . $cgi->a({-class => "header", -href => "$my_uri?" . esc_param("o=age")}, "Last Change") . "</th>\n";
870
}
871
print "<th></th>\n" .
872
"</tr>\n";
@@ -864,7 +878,7 @@ sub git_project_list {
878
print "<tr class=\"light\">\n";
879
}
880
$alternate ^= 1;
867
- print "<td>" . $cgi->a({-href => esc_url("$my_uri?p=$pr->{'path'};a=summary"), -class => "list"}, esc_html($pr->{'path'})) . "</td>\n" .
881
+ print "<td>" . $cgi->a({-href => "$my_uri?" . esc_param("p=$pr->{'path'};a=summary"), -class => "list"}, esc_html($pr->{'path'})) . "</td>\n" .
882
"<td>$pr->{'descr'}</td>\n" .
883
"<td><i>" . chop_str($pr->{'owner'}, 15) . "</i></td>\n";
884
my $colored_age;
@@ -877,9 +891,9 @@ sub git_project_list {
891
}
892
print "<td>$colored_age</td>\n" .
893
"<td class=\"link\">" .
880
- $cgi->a({-href => esc_url("$my_uri?p=$pr->{'path'};a=summary")}, "summary") .
881
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$pr->{'path'};a=shortlog")}, "shortlog") .
882
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$pr->{'path'};a=log")}, "log") .
894
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$pr->{'path'};a=summary")}, "summary") .
895
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$pr->{'path'};a=shortlog")}, "shortlog") .
896
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$pr->{'path'};a=log")}, "log") .
897
"</td>\n" .
898
"</tr>\n";
899
}
@@ -978,11 +992,11 @@ sub git_summary {
992
git_header_html();
993
print "<div class=\"page_nav\">\n" .
994
"summary".
981
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") .
982
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") .
983
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$head")}, "commit") .
984
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") .
985
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree")}, "tree") .
995
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") .
996
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log")}, "log") .
997
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$head")}, "commit") .
998
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$head")}, "commitdiff") .
999
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree")}, "tree") .
1000
"<br/><br/>\n" .
1001
"</div>\n";
1002
print "<div class=\"title\"> </div>\n";
@@ -995,7 +1009,7 @@ sub git_summary {
1009
my (@revlist) = map { chomp; $_ } <$fd>;
1010
close $fd;
1011
print "<div>\n" .
998
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog"), -class => "title"}, "shortlog") .
1012
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog"), -class => "title"}, "shortlog") .
1013
"</div>\n";
1014
my $i = 16;
1015
print "<table cellspacing=\"0\">\n";
@@ -1014,20 +1028,20 @@ sub git_summary {
1028
"<td><i>" . esc_html(chop_str($co{'author_name'}, 10)) . "</i></td>\n" .
1029
"<td>";
1030
if (length($co{'title_short'}) < length($co{'title'})) {
1017
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"},
1031
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"},
1032
"<b>" . esc_html($co{'title_short'}) . "</b>");
1033
} else {
1020
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit"), -class => "list"},
1034
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"},
1035
"<b>" . esc_html($co{'title'}) . "</b>");
1036
}
1037
print "</td>\n" .
1038
"<td class=\"link\">" .
1025
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit")}, "commit") .
1026
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
1039
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") .
1040
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
1041
"</td>\n" .
1042
"</tr>";
1043
} else {
1030
- print "<td>" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "...") . "</td>\n" .
1044
+ print "<td>" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "...") . "</td>\n" .
1045
"</tr>";
1046
last;
1047
}
@@ -1037,7 +1051,7 @@ sub git_summary {
1051
my $taglist = git_read_refs("refs/tags");
1052
if (defined @$taglist) {
1053
print "<div>\n" .
1040
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=tags"), -class => "title"}, "tags") .
1054
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tags"), -class => "title"}, "tags") .
1055
"</div>\n";
1056
my $i = 16;
1057
print "<table cellspacing=\"0\">\n";
@@ -1058,27 +1072,27 @@ sub git_summary {
1072
if ($i-- > 0) {
1073
print "<td><i>$tag{'age'}</i></td>\n" .
1074
"<td>" .
1061
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"},
1075
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"},
1076
"<b>" . esc_html($tag{'name'}) . "</b>") .
1077
"</td>\n" .
1078
"<td>";
1079
if (defined($comment)) {
1066
- print $cgi->a({-class => "list", -href => esc_url("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, $comment);
1080
+ print $cgi->a({-class => "list", -href => "$my_uri?" . esc_param("p=$project;a=tag;h=$tag{'id'}")}, $comment);
1081
}
1082
print "</td>\n" .
1083
"<td class=\"link\">";
1084
if ($tag{'type'} eq "tag") {
1071
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | ";
1085
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | ";
1086
}
1073
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'});
1087
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'});
1088
if ($tag{'reftype'} eq "commit") {
1075
- print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1076
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$tag{'refid'}")}, "log");
1089
+ print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1090
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$tag{'refid'}")}, "log");
1091
}
1092
print "</td>\n" .
1093
"</tr>";
1094
} else {
1081
- print "<td>" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tags")}, "...") . "</td>\n" .
1095
+ print "<td>" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tags")}, "...") . "</td>\n" .
1096
"</tr>";
1097
last;
1098
}
@@ -1089,7 +1103,7 @@ sub git_summary {
1103
my $headlist = git_read_refs("refs/heads");
1104
if (defined @$headlist) {
1105
print "<div>\n" .
1092
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=heads"), -class => "title"}, "heads") .
1106
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=heads"), -class => "title"}, "heads") .
1107
"</div>\n";
1108
my $i = 16;
1109
print "<table cellspacing=\"0\">\n";
@@ -1105,16 +1119,16 @@ sub git_summary {
1119
if ($i-- > 0) {
1120
print "<td><i>$tag{'age'}</i></td>\n" .
1121
"<td>" .
1108
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"},
1122
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"},
1123
"<b>" . esc_html($tag{'name'}) . "</b>") .
1124
"</td>\n" .
1125
"<td class=\"link\">" .
1112
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1113
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$tag{'name'}")}, "log") .
1126
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1127
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$tag{'name'}")}, "log") .
1128
"</td>\n" .
1129
"</tr>";
1130
} else {
1117
- print "<td>" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=heads")}, "...") . "</td>\n" .
1131
+ print "<td>" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=heads")}, "...") . "</td>\n" .
1132
"</tr>";
1133
last;
1134
}
@@ -1128,24 +1142,24 @@ sub git_tag {
1142
my $head = git_read_hash("$project/HEAD");
1143
git_header_html();
1144
print "<div class=\"page_nav\">\n" .
1131
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") .
1132
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") .
1133
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") .
1134
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$head")}, "commit") .
1135
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") .
1136
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" .
1145
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
1146
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") .
1147
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log")}, "log") .
1148
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$head")}, "commit") .
1149
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$head")}, "commitdiff") .
1150
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" .
1151
"<br/>\n" .
1152
"</div>\n";
1153
my %tag = git_read_tag($hash);
1154
print "<div>\n" .
1141
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($tag{'name'})) . "\n" .
1155
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($tag{'name'})) . "\n" .
1156
"</div>\n";
1157
print "<div class=\"title_text\">\n" .
1158
"<table cellspacing=\"0\">\n" .
1159
"<tr>\n" .
1160
"<td>object</td>\n" .
1147
- "<td>" . $cgi->a({-class => "list", -href => esc_url("$my_uri?p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'object'}) . "</td>\n" .
1148
- "<td class=\"link\">" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'type'}) . "</td>\n" .
1161
+ "<td>" . $cgi->a({-class => "list", -href => "$my_uri?" . esc_param("p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'object'}) . "</td>\n" .
1162
+ "<td class=\"link\">" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$tag{'type'};h=$tag{'object'}")}, $tag{'type'}) . "</td>\n" .
1163
"</tr>\n";
1164
if (defined($tag{'author'})) {
1165
my %ad = date_str($tag{'epoch'}, $tag{'tz'});
@@ -1167,17 +1181,17 @@ sub git_tags {
1181
my $head = git_read_hash("$project/HEAD");
1182
git_header_html();
1183
print "<div class=\"page_nav\">\n" .
1170
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") .
1171
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") .
1172
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") .
1173
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$head")}, "commit") .
1174
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") .
1175
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" .
1184
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
1185
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") .
1186
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log")}, "log") .
1187
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$head")}, "commit") .
1188
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$head")}, "commitdiff") .
1189
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" .
1190
"<br/>\n" .
1191
"</div>\n";
1192
my $taglist = git_read_refs("refs/tags");
1193
print "<div>\n" .
1180
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary"), -class => "title"}, " ") .
1194
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary"), -class => "title"}, " ") .
1195
"</div>\n";
1196
print "<table cellspacing=\"0\">\n";
1197
my $alternate = 0;
@@ -1197,22 +1211,22 @@ sub git_tags {
1211
$alternate ^= 1;
1212
print "<td><i>$tag{'age'}</i></td>\n" .
1213
"<td>" .
1200
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"},
1214
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$tag{'reftype'};h=$tag{'refid'}"), -class => "list"},
1215
"<b>" . esc_html($tag{'name'}) . "</b>") .
1216
"</td>\n" .
1217
"<td>";
1218
if (defined($comment)) {
1205
- print $cgi->a({-class => "list", -href => esc_url("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, $comment);
1219
+ print $cgi->a({-class => "list", -href => "$my_uri?" . esc_param("p=$project;a=tag;h=$tag{'id'}")}, $comment);
1220
}
1221
print "</td>\n" .
1222
"<td class=\"link\">";
1223
if ($tag{'type'} eq "tag") {
1210
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | ";
1224
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tag;h=$tag{'id'}")}, "tag") . " | ";
1225
}
1212
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'});
1226
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$tag{'reftype'};h=$tag{'refid'}")}, $tag{'reftype'});
1227
if ($tag{'reftype'} eq "commit") {
1214
- print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1215
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$tag{'refid'}")}, "log");
1228
+ print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1229
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$tag{'refid'}")}, "log");
1230
}
1231
print "</td>\n" .
1232
"</tr>";
@@ -1226,17 +1240,17 @@ sub git_heads {
1240
my $head = git_read_hash("$project/HEAD");
1241
git_header_html();
1242
print "<div class=\"page_nav\">\n" .
1229
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") .
1230
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") .
1231
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") .
1232
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$head")}, "commit") .
1233
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$head")}, "commitdiff") .
1234
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" .
1243
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
1244
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") .
1245
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log")}, "log") .
1246
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$head")}, "commit") .
1247
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$head")}, "commitdiff") .
1248
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;hb=$head")}, "tree") . "<br/>\n" .
1249
"<br/>\n" .
1250
"</div>\n";
1251
my $taglist = git_read_refs("refs/heads");
1252
print "<div>\n" .
1239
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary"), -class => "title"}, " ") .
1253
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary"), -class => "title"}, " ") .
1254
"</div>\n";
1255
print "<table cellspacing=\"0\">\n";
1256
my $alternate = 0;
@@ -1251,11 +1265,11 @@ sub git_heads {
1265
$alternate ^= 1;
1266
print "<td><i>$tag{'age'}</i></td>\n" .
1267
"<td>" .
1254
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"}, "<b>" . esc_html($tag{'name'}) . "</b>") .
1268
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$tag{'name'}"), -class => "list"}, "<b>" . esc_html($tag{'name'}) . "</b>") .
1269
"</td>\n" .
1270
"<td class=\"link\">" .
1257
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1258
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$tag{'name'}")}, "log") .
1271
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$tag{'name'}")}, "shortlog") .
1272
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$tag{'name'}")}, "log") .
1273
"</td>\n" .
1274
"</tr>";
1275
}
@@ -1303,21 +1317,21 @@ sub git_blob {
1317
git_header_html();
1318
if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
1319
print "<div class=\"page_nav\">\n" .
1306
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") .
1307
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") .
1308
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") .
1309
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash_base")}, "commit") .
1310
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") .
1311
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . "<br/>\n";
1320
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
1321
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") .
1322
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log")}, "log") .
1323
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base")}, "commit") .
1324
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") .
1325
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") . "<br/>\n";
1326
if (defined $file_name) {
1313
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob_plain;h=$hash;f=$file_name")}, "plain") .
1314
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;hb=HEAD;f=$file_name")}, "head") . "<br/>\n";
1327
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;h=$hash;f=$file_name")}, "plain") .
1328
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;hb=HEAD;f=$file_name")}, "head") . "<br/>\n";
1329
} else {
1316
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob_plain;h=$hash")}, "plain") . "<br/>\n";
1330
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob_plain;h=$hash")}, "plain") . "<br/>\n";
1331
}
1332
print "</div>\n".
1333
"<div>" .
1320
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) .
1334
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) .
1335
"</div>\n";
1336
} else {
1337
print "<div class=\"page_nav\">\n" .
@@ -1325,7 +1339,7 @@ sub git_blob {
1339
"<div class=\"title\">$hash</div>\n";
1340
}
1341
if (defined $file_name) {
1328
- print "<div class=\"page_path\"><b>$file_name</b></div>\n";
1342
+ print "<div class=\"page_path\"><b>" . esc_html($file_name) . "</b></div>\n";
1343
}
1344
print "<div class=\"page_body\">\n";
1345
my $nr;
@@ -1369,27 +1383,28 @@ sub git_tree {
1383
$hash_base = git_read_hash("$project/HEAD");
1384
}
1385
}
1372
- open my $fd, "-|", "$gitbin/git-ls-tree $hash" or die_error(undef, "Open git-ls-tree failed.");
1373
- my (@entries) = map { chomp; $_ } <$fd>;
1386
+ $/ = "\0";
1387
+ open my $fd, "-|", "$gitbin/git-ls-tree -z $hash" or die_error(undef, "Open git-ls-tree failed.");
1388
+ chomp (my (@entries) = <$fd>);
1389
close $fd or die_error(undef, "Reading tree failed.");
1390
+ $/ = "\n";
1391
1392
git_header_html();
1393
my $base_key = "";
1378
- my $file_key = "";
1394
my $base = "";
1395
if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
1396
$base_key = ";hb=$hash_base";
1397
print "<div class=\"page_nav\">\n" .
1383
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") .
1384
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash_base")}, "shortlog") .
1385
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash_base")}, "log") .
1386
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash_base")}, "commit") .
1387
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") .
1398
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
1399
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$hash_base")}, "shortlog") .
1400
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$hash_base")}, "log") .
1401
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base")}, "commit") .
1402
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") .
1403
" | tree" .
1404
"<br/><br/>\n" .
1405
"</div>\n";
1406
print "<div>\n" .
1392
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "\n" .
1407
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "\n" .
1408
"</div>\n";
1409
} else {
1410
print "<div class=\"page_nav\">\n";
@@ -1397,8 +1412,8 @@ sub git_tree {
1412
print "<div class=\"title\">$hash</div>\n";
1413
}
1414
if (defined $file_name) {
1400
- $base = "$file_name/";
1401
- print "<div class=\"page_path\"><b>/$file_name</b></div>\n";
1415
+ $base = esc_html("$file_name/");
1416
+ print "<div class=\"page_path\"><b>/" . esc_html($file_name) . "</b></div>\n";
1417
} else {
1418
print "<div class=\"page_path\"><b>/</b></div>\n";
1419
}
@@ -1412,7 +1427,7 @@ sub git_tree {
1427
my $t_type = $2;
1428
my $t_hash = $3;
1429
my $t_name = $4;
1415
- $file_key = ";f=$base$t_name";
1430
+ my $t_name = validate_input($4);
1431
if ($alternate) {
1432
print "<tr class=\"dark\">\n";
1433
} else {
@@ -1422,18 +1437,18 @@ sub git_tree {
1437
print "<td style=\"font-family:monospace\">" . mode_str($t_mode) . "</td>\n";
1438
if ($t_type eq "blob") {
1439
print "<td class=\"list\">" .
1425
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key), -class => "list"}, $t_name) .
1440
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name"), -class => "list"}, esc_html($t_name)) .
1441
"</td>\n" .
1442
"<td class=\"link\">" .
1428
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$t_hash" . $base_key . $file_key)}, "blob") .
1429
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=history;h=$hash_base" . $file_key)}, "history") .
1443
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$t_hash$base_key;f=$base$t_name")}, "blob") .
1444
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;h=$hash_base;f=$base$t_name")}, "history") .
1445
"</td>\n";
1446
} elsif ($t_type eq "tree") {
1447
print "<td class=\"list\">" .
1433
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key)}, $t_name) .
1448
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$t_hash$base_key;f=$base$t_name")}, esc_html($t_name)) .
1449
"</td>\n" .
1450
"<td class=\"link\">" .
1436
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$t_hash" . $base_key . $file_key)}, "tree") .
1451
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$t_hash$base_key;f=$base$t_name")}, "tree") .
1452
"</td>\n";
1453
}
1454
print "</tr>\n";
@@ -1489,7 +1504,8 @@ sub git_rss {
1504
if (!($line =~ m/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$/)) {
1505
next;
1506
}
1492
- my $file = $7;
1507
+ my $file = validate_input(unquote($7));
1508
+ $file = decode("utf8", $file, Encode::FB_DEFAULT);
1509
print "$file<br/>\n";
1510
}
1511
print "]]>\n" .
@@ -1543,12 +1559,12 @@ sub git_log {
1559
}
1560
git_header_html();
1561
print "<div class=\"page_nav\">\n";
1546
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") .
1547
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash")}, "shortlog") .
1562
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
1563
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$hash")}, "shortlog") .
1564
" | log" .
1549
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash")}, "commit") .
1550
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
1551
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n";
1565
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash")}, "commit") .
1566
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
1567
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n";
1568
1569
my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
1570
open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed.");
@@ -1556,19 +1572,19 @@ sub git_log {
1572
close $fd;
1573
1574
if ($hash ne $head || $page) {
1559
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "HEAD");
1575
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log")}, "HEAD");
1576
} else {
1577
print "HEAD";
1578
}
1579
if ($page > 0) {
1580
print " ⋅ " .
1565
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash;pg=" . ($page-1)), -accesskey => "p", -title => "Alt-p"}, "prev");
1581
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$hash;pg=" . ($page-1)), -accesskey => "p", -title => "Alt-p"}, "prev");
1582
} else {
1583
print " ⋅ prev";
1584
}
1585
if ($#revlist >= (100 * ($page+1)-1)) {
1586
print " ⋅ " .
1571
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash;pg=" . ($page+1)), -accesskey => "n", -title => "Alt-n"}, "next");
1587
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$hash;pg=" . ($page+1)), -accesskey => "n", -title => "Alt-n"}, "next");
1588
} else {
1589
print " ⋅ next";
1590
}
@@ -1576,7 +1592,7 @@ sub git_log {
1592
"</div>\n";
1593
if (!@revlist) {
1594
print "<div>\n" .
1579
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary"), -class => "title"}, " ") .
1595
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary"), -class => "title"}, " ") .
1596
"</div>\n";
1597
my %co = git_read_commit($hash);
1598
print "<div class=\"page_body\"> Last change $co{'age_string'}.<br/><br/></div>\n";
@@ -1587,13 +1603,13 @@ sub git_log {
1603
next if !%co;
1604
my %ad = date_str($co{'author_epoch'});
1605
print "<div>\n" .
1590
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit"), -class => "title"},
1606
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "title"},
1607
"<span class=\"age\">$co{'age_string'}</span>" . esc_html($co{'title'})) . "\n" .
1608
"</div>\n";
1609
print "<div class=\"title_text\">\n" .
1610
"<div class=\"log_link\">\n" .
1595
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit")}, "commit") .
1596
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
1611
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") .
1612
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
1613
"<br/>\n" .
1614
"</div>\n" .
1615
"<i>" . esc_html($co{'author_name'}) . " [$ad{'rfc2822'}]</i><br/>\n" .
@@ -1649,22 +1665,22 @@ sub git_commit {
1665
}
1666
git_header_html(undef, $expires);
1667
print "<div class=\"page_nav\">\n" .
1652
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") .
1653
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash")}, "shortlog") .
1654
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash")}, "log") .
1668
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
1669
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$hash")}, "shortlog") .
1670
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$hash")}, "log") .
1671
" | commit";
1672
if (defined $co{'parent'}) {
1657
- print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff");
1673
+ print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash")}, "commitdiff");
1674
}
1659
- print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "\n" .
1675
+ print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "\n" .
1676
"<br/><br/></div>\n";
1677
if (defined $co{'parent'}) {
1678
print "<div>\n" .
1663
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" .
1679
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" .
1680
"</div>\n";
1681
} else {
1682
print "<div>\n" .
1667
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" .
1683
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" .
1684
"</div>\n";
1685
}
1686
print "<div class=\"title_text\">\n" .
@@ -1685,19 +1701,19 @@ sub git_commit {
1701
print "<tr>" .
1702
"<td>tree</td>" .
1703
"<td style=\"font-family:monospace\">" .
1688
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash"), class => "list"}, $co{'tree'}) .
1704
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash"), class => "list"}, $co{'tree'}) .
1705
"</td>" .
1690
- "<td class=\"link\">" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") .
1706
+ "<td class=\"link\">" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") .
1707
"</td>" .
1708
"</tr>\n";
1709
my $parents = $co{'parents'};
1710
foreach my $par (@$parents) {
1711
print "<tr>" .
1712
"<td>parent</td>" .
1697
- "<td style=\"font-family:monospace\">" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$par"), class => "list"}, $par) . "</td>" .
1713
+ "<td style=\"font-family:monospace\">" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$par"), class => "list"}, $par) . "</td>" .
1714
"<td class=\"link\">" .
1699
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$par")}, "commit") .
1700
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash;hp=$par")}, "commitdiff") .
1715
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$par")}, "commit") .
1716
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash;hp=$par")}, "commitdiff") .
1717
"</td>" .
1718
"</tr>\n";
1719
}
@@ -1745,7 +1761,7 @@ sub git_commit {
1761
my $to_id = $4;
1762
my $status = $5;
1763
my $similarity = $6;
1748
- my $file = $7;
1764
+ my $file = validate_input(unquote($7));
1765
if ($alternate) {
1766
print "<tr class=\"dark\">\n";
1767
} else {
@@ -1758,16 +1774,16 @@ sub git_commit {
1774
$mode_chng = sprintf(" with mode: %04o", (oct $to_mode) & 0777);
1775
}
1776
print "<td>" .
1761
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file)) . "</td>\n" .
1777
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file)) . "</td>\n" .
1778
"<td><span style=\"color: #008000;\">[new " . file_type($to_mode) . "$mode_chng]</span></td>\n" .
1763
- "<td class=\"link\">" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob") . "</td>\n";
1779
+ "<td class=\"link\">" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob") . "</td>\n";
1780
} elsif ($status eq "D") {
1781
print "<td>" .
1766
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file)) . "</td>\n" .
1782
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file)) . "</td>\n" .
1783
"<td><span style=\"color: #c00000;\">[deleted " . file_type($from_mode). "]</span></td>\n" .
1784
"<td class=\"link\">" .
1769
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, "blob") .
1770
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=history;h=$hash;f=$file")}, "history") .
1785
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, "blob") .
1786
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;h=$hash;f=$file")}, "history") .
1787
"</td>\n"
1788
} elsif ($status eq "M" || $status eq "T") {
1789
my $mode_chnge = "";
@@ -1787,18 +1803,18 @@ sub git_commit {
1803
}
1804
print "<td>";
1805
if ($to_id ne $from_id) {
1790
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file));
1806
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file));
1807
} else {
1792
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file));
1808
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file"), -class => "list"}, esc_html($file));
1809
}
1810
print "</td>\n" .
1811
"<td>$mode_chnge</td>\n" .
1812
"<td class=\"link\">";
1797
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob");
1813
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, "blob");
1814
if ($to_id ne $from_id) {
1799
- print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file")}, "diff");
1815
+ print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$file")}, "diff");
1816
}
1801
- print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=history;h=$hash;f=$file")}, "history") . "\n";
1817
+ print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=history;h=$hash;f=$file")}, "history") . "\n";
1818
print "</td>\n";
1819
} elsif ($status eq "R") {
1820
my ($from_file, $to_file) = split "\t", $file;
@@ -1807,14 +1823,14 @@ sub git_commit {
1823
$mode_chng = sprintf(", mode: %04o", (oct $to_mode) & 0777);
1824
}
1825
print "<td>" .
1810
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file"), -class => "list"}, esc_html($to_file)) . "</td>\n" .
1826
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file"), -class => "list"}, esc_html($to_file)) . "</td>\n" .
1827
"<td><span style=\"color: #777777;\">[moved from " .
1812
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$from_file"), -class => "list"}, esc_html($from_file)) .
1828
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$hash;f=$from_file"), -class => "list"}, esc_html($from_file)) .
1829
" with " . (int $similarity) . "% similarity$mode_chng]</span></td>\n" .
1830
"<td class=\"link\">" .
1815
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file")}, "blob");
1831
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$to_file")}, "blob");
1832
if ($to_id ne $from_id) {
1817
- print " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file")}, "diff");
1833
+ print " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blobdiff;h=$to_id;hp=$from_id;hb=$hash;f=$to_file")}, "diff");
1834
}
1835
print "</td>\n";
1836
}
@@ -1829,17 +1845,17 @@ sub git_blobdiff {
1845
git_header_html();
1846
if (defined $hash_base && (my %co = git_read_commit($hash_base))) {
1847
print "<div class=\"page_nav\">\n" .
1832
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") .
1833
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") .
1834
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") .
1835
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash_base")}, "commit") .
1836
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") .
1837
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") .
1848
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
1849
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") .
1850
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log")}, "log") .
1851
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base")}, "commit") .
1852
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash_base")}, "commitdiff") .
1853
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash_base")}, "tree") .
1854
"<br/>\n";
1839
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent")}, "plain") .
1855
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blobdiff_plain;h=$hash;hp=$hash_parent")}, "plain") .
1856
"</div>\n";
1857
print "<div>\n" .
1842
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "\n" .
1858
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash_base"), -class => "title"}, esc_html($co{'title'})) . "\n" .
1859
"</div>\n";
1860
} else {
1861
print "<div class=\"page_nav\">\n" .
@@ -1847,13 +1863,13 @@ sub git_blobdiff {
1863
"<div class=\"title\">$hash vs $hash_parent</div>\n";
1864
}
1865
if (defined $file_name) {
1850
- print "<div class=\"page_path\"><b>/$file_name</b></div>\n";
1866
+ print "<div class=\"page_path\"><b>/" . esc_html($file_name) . "</b></div>\n";
1867
}
1868
print "<div class=\"page_body\">\n" .
1869
"<div class=\"diff_info\">blob:" .
1854
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name")}, $hash_parent) .
1870
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$hash_parent;hb=$hash_base;f=$file_name")}, $hash_parent) .
1871
" -> blob:" .
1856
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, $hash) .
1872
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$hash;hb=$hash_base;f=$file_name")}, $hash) .
1873
"</div>\n";
1874
git_diff_print($hash_parent, $file_name || $hash_parent, $hash, $file_name || $hash);
1875
print "</div>";
@@ -1886,16 +1902,16 @@ sub git_commitdiff {
1902
}
1903
git_header_html(undef, $expires);
1904
print "<div class=\"page_nav\">\n" .
1889
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") .
1890
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash")}, "shortlog") .
1891
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash")}, "log") .
1892
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash")}, "commit") .
1905
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
1906
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$hash")}, "shortlog") .
1907
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$hash")}, "log") .
1908
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash")}, "commit") .
1909
" | commitdiff" .
1894
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "<br/>\n";
1895
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . "\n" .
1910
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") . "<br/>\n";
1911
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff_plain;h=$hash;hp=$hash_parent")}, "plain") . "\n" .
1912
"</div>\n";
1913
print "<div>\n" .
1898
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" .
1914
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" .
1915
"</div>\n";
1916
print "<div class=\"page_body\">\n";
1917
my $comment = $co{'comment'};
@@ -1931,23 +1947,23 @@ sub git_commitdiff {
1947
my $from_id = $3;
1948
my $to_id = $4;
1949
my $status = $5;
1934
- my $file = $6;
1950
+ my $file = validate_input(unquote($6));
1951
if ($status eq "A") {
1952
print "<div class=\"diff_info\">" . file_type($to_mode) . ":" .
1937
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id) . "(new)" .
1953
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id) . "(new)" .
1954
"</div>\n";
1955
git_diff_print(undef, "/dev/null", $to_id, "b/$file");
1956
} elsif ($status eq "D") {
1957
print "<div class=\"diff_info\">" . file_type($from_mode) . ":" .
1942
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) . "(deleted)" .
1958
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) . "(deleted)" .
1959
"</div>\n";
1960
git_diff_print($from_id, "a/$file", undef, "/dev/null");
1961
} elsif ($status eq "M") {
1962
if ($from_id ne $to_id) {
1963
print "<div class=\"diff_info\">" .
1948
- file_type($from_mode) . ":" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) .
1964
+ file_type($from_mode) . ":" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$from_id;hb=$hash;f=$file")}, $from_id) .
1965
" -> " .
1950
- file_type($to_mode) . ":" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id);
1966
+ file_type($to_mode) . ":" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$to_id;hb=$hash;f=$file")}, $to_id);
1967
print "</div>\n";
1968
git_diff_print($from_id, "a/$file", $to_id, "b/$file");
1969
}
@@ -2028,18 +2044,18 @@ sub git_history {
2044
}
2045
git_header_html();
2046
print "<div class=\"page_nav\">\n" .
2031
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") .
2032
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") .
2033
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log")}, "log") .
2034
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash")}, "commit") .
2035
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
2036
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") .
2047
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
2048
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") .
2049
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log")}, "log") .
2050
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash")}, "commit") .
2051
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
2052
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") .
2053
"<br/><br/>\n" .
2054
"</div>\n";
2055
print "<div>\n" .
2040
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" .
2056
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" .
2057
"</div>\n";
2042
- print "<div class=\"page_path\"><b>/$file_name</b><br/></div>\n";
2058
+ print "<div class=\"page_path\"><b>/" . esc_html($file_name) . "</b><br/></div>\n";
2059
2060
open my $fd, "-|", "$gitbin/git-rev-list $hash | $gitbin/git-diff-tree -r --stdin \'$file_name\'";
2061
my $commit;
@@ -2063,17 +2079,17 @@ sub git_history {
2079
$alternate ^= 1;
2080
print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2081
"<td><i>" . esc_html(chop_str($co{'author_name'}, 15, 3)) . "</i></td>\n" .
2066
- "<td>" . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" .
2082
+ "<td>" . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"}, "<b>" .
2083
esc_html(chop_str($co{'title'}, 50)) . "</b>") . "</td>\n" .
2084
"<td class=\"link\">" .
2069
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit")}, "commit") .
2070
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
2071
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;hb=$commit;f=$file_name")}, "blob");
2085
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") .
2086
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
2087
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;hb=$commit;f=$file_name")}, "blob");
2088
my $blob = git_get_hash_by_path($hash, $file_name);
2089
my $blob_parent = git_get_hash_by_path($commit, $file_name);
2090
if (defined $blob && defined $blob_parent && $blob ne $blob_parent) {
2091
print " | " .
2076
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name")},
2092
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blobdiff;h=$blob;hp=$blob_parent;hb=$commit;f=$file_name")},
2093
"diff to current");
2094
}
2095
print "</td>\n" .
@@ -2113,17 +2129,17 @@ sub git_search {
2129
}
2130
git_header_html();
2131
print "<div class=\"page_nav\">\n" .
2116
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary;h=$hash")}, "summary") .
2117
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "shortlog") .
2118
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash")}, "log") .
2119
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash")}, "commit") .
2120
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
2121
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") .
2132
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary;h=$hash")}, "summary") .
2133
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "shortlog") .
2134
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$hash")}, "log") .
2135
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash")}, "commit") .
2136
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
2137
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$hash")}, "tree") .
2138
"<br/><br/>\n" .
2139
"</div>\n";
2140
2141
print "<div>\n" .
2126
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" .
2142
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash"), -class => "title"}, esc_html($co{'title'})) . "\n" .
2143
"</div>\n";
2144
print "<table cellspacing=\"0\">\n";
2145
my $alternate = 0;
@@ -2154,7 +2170,7 @@ sub git_search {
2170
print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2171
"<td><i>" . esc_html(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" .
2172
"<td>" .
2157
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" . esc_html(chop_str($co{'title'}, 50)) . "</b><br/>");
2173
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" . esc_html(chop_str($co{'title'}, 50)) . "</b><br/>");
2174
my $comment = $co{'comment'};
2175
foreach my $line (@$comment) {
2176
if ($line =~ m/^(.*)($searchtext)(.*)$/i) {
@@ -2169,8 +2185,8 @@ sub git_search {
2185
}
2186
print "</td>\n" .
2187
"<td class=\"link\">" .
2172
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$co{'id'}")}, "commit") .
2173
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree");
2188
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$co{'id'}")}, "commit") .
2189
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree");
2190
print "</td>\n" .
2191
"</tr>\n";
2192
}
@@ -2207,18 +2223,18 @@ sub git_search {
2223
print "<td title=\"$co{'age_string_age'}\"><i>$co{'age_string_date'}</i></td>\n" .
2224
"<td><i>" . esc_html(chop_str($co{'author_name'}, 15, 5)) . "</i></td>\n" .
2225
"<td>" .
2210
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" .
2226
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$co{'id'}"), -class => "list"}, "<b>" .
2227
esc_html(chop_str($co{'title'}, 50)) . "</b><br/>");
2228
while (my $setref = shift @files) {
2229
my %set = %$setref;
2214
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}"), class => "list"},
2230
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=blob;h=$set{'id'};hb=$co{'id'};f=$set{'file'}"), class => "list"},
2231
"<span style=\"color:#e00000\">" . esc_html($set{'file'}) . "</span>") .
2232
"<br/>\n";
2233
}
2234
print "</td>\n" .
2235
"<td class=\"link\">" .
2220
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$co{'id'}")}, "commit") .
2221
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree");
2236
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$co{'id'}")}, "commit") .
2237
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$co{'tree'};hb=$co{'id'}")}, "tree");
2238
print "</td>\n" .
2239
"</tr>\n";
2240
}
@@ -2241,12 +2257,12 @@ sub git_shortlog {
2257
}
2258
git_header_html();
2259
print "<div class=\"page_nav\">\n" .
2244
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary")}, "summary") .
2260
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary")}, "summary") .
2261
" | shortlog" .
2246
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=log;h=$hash")}, "log") .
2247
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$hash")}, "commit") .
2248
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
2249
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n";
2262
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=log;h=$hash")}, "log") .
2263
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$hash")}, "commit") .
2264
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$hash")}, "commitdiff") .
2265
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=tree;h=$hash;hb=$hash")}, "tree") . "<br/>\n";
2266
2267
my $limit = sprintf("--max-count=%i", (100 * ($page+1)));
2268
open my $fd, "-|", "$gitbin/git-rev-list $limit $hash" or die_error(undef, "Open failed.");
@@ -2254,26 +2270,26 @@ sub git_shortlog {
2270
close $fd;
2271
2272
if ($hash ne $head || $page) {
2257
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog")}, "HEAD");
2273
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog")}, "HEAD");
2274
} else {
2275
print "HEAD";
2276
}
2277
if ($page > 0) {
2278
print " ⋅ " .
2263
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page-1)), -accesskey => "p", -title => "Alt-p"}, "prev");
2279
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$hash;pg=" . ($page-1)), -accesskey => "p", -title => "Alt-p"}, "prev");
2280
} else {
2281
print " ⋅ prev";
2282
}
2283
if ($#revlist >= (100 * ($page+1)-1)) {
2284
print " ⋅ " .
2269
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -accesskey => "n", -title => "Alt-n"}, "next");
2285
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -accesskey => "n", -title => "Alt-n"}, "next");
2286
} else {
2287
print " ⋅ next";
2288
}
2289
print "<br/>\n" .
2290
"</div>\n";
2291
print "<div>\n" .
2276
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=summary"), -class => "title"}, " ") .
2292
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=summary"), -class => "title"}, " ") .
2293
"</div>\n";
2294
print "<table cellspacing=\"0\">\n";
2295
my $alternate = 0;
@@ -2291,23 +2307,23 @@ sub git_shortlog {
2307
"<td><i>" . esc_html(chop_str($co{'author_name'}, 10)) . "</i></td>\n" .
2308
"<td>";
2309
if (length($co{'title_short'}) < length($co{'title'})) {
2294
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"},
2310
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list", -title => "$co{'title'}"},
2311
"<b>" . esc_html($co{'title_short'}) . "</b>");
2312
} else {
2297
- print $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit"), -class => "list"},
2313
+ print $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit"), -class => "list"},
2314
"<b>" . esc_html($co{'title_short'}) . "</b>");
2315
}
2316
print "</td>\n" .
2317
"<td class=\"link\">" .
2302
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=commit;h=$commit")}, "commit") .
2303
- " | " . $cgi->a({-href => esc_url("$my_uri?p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
2318
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") .
2319
+ " | " . $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commitdiff;h=$commit")}, "commitdiff") .
2320
"</td>\n" .
2321
"</tr>";
2322
}
2323
if ($#revlist >= (100 * ($page+1)-1)) {
2324
print "<tr>\n" .
2325
"<td>" .
2310
- $cgi->a({-href => esc_url("$my_uri?p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -title => "Alt-n"}, "next") .
2326
+ $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=shortlog;h=$hash;pg=" . ($page+1)), -title => "Alt-n"}, "next") .
2327
"</td>\n" .
2328
"</tr>\n";
2329
}