Skip to content

Commit 2b380d8

Browse files
committed
Merge branch 'jn/maint-gitweb-utf8-fix'
* jn/maint-gitweb-utf8-fix: gitweb: Fix fallback mode of to_utf8 subroutine gitweb: Output valid utf8 in git_blame_common('data') gitweb: esc_html() site name for title in OPML gitweb: Call to_utf8() on input string in chop_and_escape_str()
2 parents 5d6dfc7 + b13e3ea commit 2b380d8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

gitweb/gitweb.perl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,8 +1443,8 @@ sub validate_refname {
14431443
sub to_utf8 {
14441444
my $str = shift;
14451445
return undef unless defined $str;
1446-
if (utf8::valid($str)) {
1447-
utf8::decode($str);
1446+
1447+
if (utf8::is_utf8($str) || utf8::decode($str)) {
14481448
return $str;
14491449
} else {
14501450
return decode($fallback_encoding, $str, Encode::FB_DEFAULT);
@@ -1696,6 +1696,7 @@ sub chop_and_escape_str {
16961696
my ($str) = @_;
16971697

16981698
my $chopped = chop_str(@_);
1699+
$str = to_utf8($str);
16991700
if ($chopped eq $str) {
17001701
return esc_html($chopped);
17011702
} else {
@@ -6243,7 +6244,9 @@ sub git_blame_common {
62436244
-type=>"text/plain", -charset => "utf-8",
62446245
-status=> "200 OK");
62456246
local $| = 1; # output autoflush
6246-
print while <$fd>;
6247+
while (my $line = <$fd>) {
6248+
print to_utf8($line);
6249+
}
62476250
close $fd
62486251
or print "ERROR $!\n";
62496252

@@ -7862,11 +7865,12 @@ sub git_opml {
78627865
-charset => 'utf-8',
78637866
-content_disposition => 'inline; filename="opml.xml"');
78647867

7868+
my $title = esc_html($site_name);
78657869
print <<XML;
78667870
<?xml version="1.0" encoding="utf-8"?>
78677871
<opml version="1.0">
78687872
<head>
7869-
<title>$site_name OPML Export</title>
7873+
<title>$title OPML Export</title>
78707874
</head>
78717875
<body>
78727876
<outline text="git RSS feeds">

0 commit comments

Comments
 (0)