Skip to content

Commit

Permalink
gitweb: Convert generated contents to utf8 in commitdiff_plain
Browse files Browse the repository at this point in the history
If the commit message, or commit author contains non-ascii, it must be
converted from Perl internal representation to utf-8, to follow what
got declared in HTTP header.  Use to_utf8() to do the conversion.

This necessarily replaces here-doc with "print" statements.

Signed-off-by: Yasushi SHOJI <[email protected]>
Acked-by: İsmail Dönmez <[email protected]>
Acked-by: Jakub Narebski <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
yashi authored and gitster committed Jan 30, 2008
1 parent ab989ad commit 7720224
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -5048,16 +5048,15 @@ sub git_commitdiff {
-expires => $expires,
-content_disposition => 'inline; filename="' . "$filename" . '"');
my %ad = parse_date($co{'author_epoch'}, $co{'author_tz'});
print <<TEXT;
From: $co{'author'}
Date: $ad{'rfc2822'} ($ad{'tz_local'})
Subject: $co{'title'}
TEXT
print "From: " . to_utf8($co{'author'}) . "\n";
print "Date: $ad{'rfc2822'} ($ad{'tz_local'})\n";
print "Subject: " . to_utf8($co{'title'}) . "\n";

print "X-Git-Tag: $tagname\n" if $tagname;
print "X-Git-Url: " . $cgi->self_url() . "\n\n";

foreach my $line (@{$co{'comment'}}) {
print "$line\n";
print to_utf8($line) . "\n";
}
print "---\n\n";
}
Expand Down

0 comments on commit 7720224

Please sign in to comment.