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()maint
commit
b15840e5b8
|
@ -1442,8 +1442,8 @@ sub validate_refname {
|
||||||
sub to_utf8 {
|
sub to_utf8 {
|
||||||
my $str = shift;
|
my $str = shift;
|
||||||
return undef unless defined $str;
|
return undef unless defined $str;
|
||||||
if (utf8::valid($str)) {
|
|
||||||
utf8::decode($str);
|
if (utf8::is_utf8($str) || utf8::decode($str)) {
|
||||||
return $str;
|
return $str;
|
||||||
} else {
|
} else {
|
||||||
return decode($fallback_encoding, $str, Encode::FB_DEFAULT);
|
return decode($fallback_encoding, $str, Encode::FB_DEFAULT);
|
||||||
|
@ -1695,6 +1695,7 @@ sub chop_and_escape_str {
|
||||||
my ($str) = @_;
|
my ($str) = @_;
|
||||||
|
|
||||||
my $chopped = chop_str(@_);
|
my $chopped = chop_str(@_);
|
||||||
|
$str = to_utf8($str);
|
||||||
if ($chopped eq $str) {
|
if ($chopped eq $str) {
|
||||||
return esc_html($chopped);
|
return esc_html($chopped);
|
||||||
} else {
|
} else {
|
||||||
|
@ -6107,7 +6108,9 @@ sub git_blame_common {
|
||||||
-type=>"text/plain", -charset => "utf-8",
|
-type=>"text/plain", -charset => "utf-8",
|
||||||
-status=> "200 OK");
|
-status=> "200 OK");
|
||||||
local $| = 1; # output autoflush
|
local $| = 1; # output autoflush
|
||||||
print while <$fd>;
|
while (my $line = <$fd>) {
|
||||||
|
print to_utf8($line);
|
||||||
|
}
|
||||||
close $fd
|
close $fd
|
||||||
or print "ERROR $!\n";
|
or print "ERROR $!\n";
|
||||||
|
|
||||||
|
@ -7699,11 +7702,12 @@ sub git_opml {
|
||||||
-charset => 'utf-8',
|
-charset => 'utf-8',
|
||||||
-content_disposition => 'inline; filename="opml.xml"');
|
-content_disposition => 'inline; filename="opml.xml"');
|
||||||
|
|
||||||
|
my $title = esc_html($site_name);
|
||||||
print <<XML;
|
print <<XML;
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<opml version="1.0">
|
<opml version="1.0">
|
||||||
<head>
|
<head>
|
||||||
<title>$site_name OPML Export</title>
|
<title>$title OPML Export</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<outline text="git RSS feeds">
|
<outline text="git RSS feeds">
|
||||||
|
|
Loading…
Reference in New Issue