Skip to content

Commit b15840e

Browse files
committed
Merge branch 'jn/maint-gitweb-utf8-fix' into maint
* 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 cfdfc5a + b13e3ea commit b15840e

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
@@ -1442,8 +1442,8 @@ sub validate_refname {
14421442
sub to_utf8 {
14431443
my $str = shift;
14441444
return undef unless defined $str;
1445-
if (utf8::valid($str)) {
1446-
utf8::decode($str);
1445+
1446+
if (utf8::is_utf8($str) || utf8::decode($str)) {
14471447
return $str;
14481448
} else {
14491449
return decode($fallback_encoding, $str, Encode::FB_DEFAULT);
@@ -1695,6 +1695,7 @@ sub chop_and_escape_str {
16951695
my ($str) = @_;
16961696

16971697
my $chopped = chop_str(@_);
1698+
$str = to_utf8($str);
16981699
if ($chopped eq $str) {
16991700
return esc_html($chopped);
17001701
} else {
@@ -6107,7 +6108,9 @@ sub git_blame_common {
61076108
-type=>"text/plain", -charset => "utf-8",
61086109
-status=> "200 OK");
61096110
local $| = 1; # output autoflush
6110-
print while <$fd>;
6111+
while (my $line = <$fd>) {
6112+
print to_utf8($line);
6113+
}
61116114
close $fd
61126115
or print "ERROR $!\n";
61136116

@@ -7699,11 +7702,12 @@ sub git_opml {
76997702
-charset => 'utf-8',
77007703
-content_disposition => 'inline; filename="opml.xml"');
77017704

7705+
my $title = esc_html($site_name);
77027706
print <<XML;
77037707
<?xml version="1.0" encoding="utf-8"?>
77047708
<opml version="1.0">
77057709
<head>
7706-
<title>$site_name OPML Export</title>
7710+
<title>$title OPML Export</title>
77077711
</head>
77087712
<body>
77097713
<outline text="git RSS feeds">

0 commit comments

Comments
 (0)