Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
gitweb: use decode_utf8 directly
author
Ismail Dönmez
<ismail@pardus.org.tr>
Tue, 1 May 2007 21:12:13 +0000
(
00:12
+0300)
committer
Junio C Hamano
<junkio@cox.net>
Fri, 4 May 2007 06:22:12 +0000
(23:22 -0700)
Using decode() tries to decode data that is already UTF-8 and
borks, but decode_utf8 from Encode.pm has a built-in safety
against that.
Signed-off-by: Junio C Hamano <junkio@cox.net>
gitweb/gitweb.perl
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
c256acb
)
diff --git
a/gitweb/gitweb.perl
b/gitweb/gitweb.perl
index 45ac9d7121e30e85f19380b7a44c6f228dc73444..12c2e6685ec9378d43433d1f73b6f2c13c4f7ffd 100755
(executable)
--- a/
gitweb/gitweb.perl
+++ b/
gitweb/gitweb.perl
@@
-560,12
+560,6
@@
sub validate_refname {
return $input;
}
return $input;
}
-# very thin wrapper for decode("utf8", $str, Encode::FB_DEFAULT);
-sub to_utf8 {
- my $str = shift;
- return decode("utf8", $str, Encode::FB_DEFAULT);
-}
-
# quote unsafe chars, but keep the slash, even when it's not
# correct, but quoted slashes look too horrible in bookmarks
sub esc_param {
# quote unsafe chars, but keep the slash, even when it's not
# correct, but quoted slashes look too horrible in bookmarks
sub esc_param {
@@
-590,7
+584,7
@@
($;%)
my $str = shift;
my %opts = @_;
my $str = shift;
my %opts = @_;
- $str =
to
_utf8($str);
+ $str =
decode
_utf8($str);
$str = $cgi->escapeHTML($str);
if ($opts{'-nbsp'}) {
$str =~ s/ / /g;
$str = $cgi->escapeHTML($str);
if ($opts{'-nbsp'}) {
$str =~ s/ / /g;
@@
-604,7
+598,7
@@
sub esc_path {
my $str = shift;
my %opts = @_;
my $str = shift;
my %opts = @_;
- $str =
to
_utf8($str);
+ $str =
decode
_utf8($str);
$str = $cgi->escapeHTML($str);
if ($opts{'-nbsp'}) {
$str =~ s/ / /g;
$str = $cgi->escapeHTML($str);
if ($opts{'-nbsp'}) {
$str =~ s/ / /g;
@@
-887,7
+881,7
@@
sub format_subject_html {
if (length($short) < length($long)) {
return $cgi->a({-href => $href, -class => "list subject",
if (length($short) < length($long)) {
return $cgi->a({-href => $href, -class => "list subject",
- -title =>
to
_utf8($long)},
+ -title =>
decode
_utf8($long)},
esc_html($short) . $extra);
} else {
return $cgi->a({-href => $href, -class => "list subject"},
esc_html($short) . $extra);
} else {
return $cgi->a({-href => $href, -class => "list subject"},
@@
-1104,7
+1098,7
@@
sub git_get_projects_list {
if (check_export_ok("$projectroot/$path")) {
my $pr = {
path => $path,
if (check_export_ok("$projectroot/$path")) {
my $pr = {
path => $path,
- owner =>
to
_utf8($owner),
+ owner =>
decode
_utf8($owner),
};
push @list, $pr
}
};
push @list, $pr
}
@@
-1133,7
+1127,7
@@
sub git_get_project_owner {
$pr = unescape($pr);
$ow = unescape($ow);
if ($pr eq $project) {
$pr = unescape($pr);
$ow = unescape($ow);
if ($pr eq $project) {
- $owner =
to
_utf8($ow);
+ $owner =
decode
_utf8($ow);
last;
}
}
last;
}
}
@@
-1607,7
+1601,7
@@
sub get_file_owner {
}
my $owner = $gcos;
$owner =~ s/[,;].*$//;
}
my $owner = $gcos;
$owner =~ s/[,;].*$//;
- return
to
_utf8($owner);
+ return
decode
_utf8($owner);
}
## ......................................................................
}
## ......................................................................
@@
-1690,7
+1684,7
@@
sub git_header_html {
my $title = "$site_name";
if (defined $project) {
my $title = "$site_name";
if (defined $project) {
- $title .= " - " .
to
_utf8($project);
+ $title .= " - " .
decode
_utf8($project);
if (defined $action) {
$title .= "/$action";
if (defined $file_name) {
if (defined $action) {
$title .= "/$action";
if (defined $file_name) {
@@
-1963,7
+1957,7
@@
sub git_print_page_path {
print "<div class=\"page_path\">";
print $cgi->a({-href => href(action=>"tree", hash_base=>$hb),
print "<div class=\"page_path\">";
print $cgi->a({-href => href(action=>"tree", hash_base=>$hb),
- -title => 'tree root'},
to
_utf8("[$project]"));
+ -title => 'tree root'},
decode
_utf8("[$project]"));
print " / ";
if (defined $name) {
my @dirname = split '/', $name;
print " / ";
if (defined $name) {
my @dirname = split '/', $name;
@@
-2578,7
+2572,7
@@
sub git_project_list_body {
($pr->{'age'}, $pr->{'age_string'}) = @aa;
if (!defined $pr->{'descr'}) {
my $descr = git_get_project_description($pr->{'path'}) || "";
($pr->{'age'}, $pr->{'age_string'}) = @aa;
if (!defined $pr->{'descr'}) {
my $descr = git_get_project_description($pr->{'path'}) || "";
- $pr->{'descr_long'} =
to
_utf8($descr);
+ $pr->{'descr_long'} =
decode
_utf8($descr);
$pr->{'descr'} = chop_str($descr, 25, 5);
}
if (!defined $pr->{'owner'}) {
$pr->{'descr'} = chop_str($descr, 25, 5);
}
if (!defined $pr->{'owner'}) {
@@
-3610,7
+3604,7
@@
sub git_snapshot {
$hash = git_get_head_hash($project);
}
$hash = git_get_head_hash($project);
}
- my $filename =
to
_utf8(basename($project)) . "-$hash.tar.$suffix";
+ my $filename =
decode
_utf8(basename($project)) . "-$hash.tar.$suffix";
print $cgi->header(
-type => "application/$ctype",
print $cgi->header(
-type => "application/$ctype",