threads / patch / 29031

patchgitweb: Output valid utf8 in git_blame_common('data')

Subject: [PATCH] gitweb: Output valid utf8 in git_blame_common('data')

## tl;dr

2 messages between Nov 27, 2011 and Nov 29, 2011. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Jürgen Kreileder· Nov 27, 2011, 23:52 UTC · lore

With javascript-actions enabled gitweb showed broken author names in the tooltips on blame pages.

Signed-off-by: Juergen Kreileder <jk@blackdown.de>
---
 gitweb/gitweb.perl |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
Show changes to gitweb/gitweb.perl +3 −1
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 4f0c3bd..c863afe 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -6107,7 +6107,9 @@ sub git_blame_common {
 			-type=>"text/plain", -charset => "utf-8",
 			-status=> "200 OK");
 		local $| = 1; # output autoflush
-		print while <$fd>;
+		while (my $line = <$fd>) {
+			print to_utf8($line);
+		}
 		close $fd
 			or print "ERROR $!\n";
-- 
1.7.5.4
Jakub Narebski· Nov 29, 2011, 19:46 UTC · re: Jürgen Kreileder · lore

Re: [PATCH] gitweb: Output valid utf8 in git_blame_common('data')

Jürgen Kreileder <jk@blackdown.de> writes:
Show 24 quoted lines
> With javascript-actions enabled gitweb showed broken author names in
> the tooltips on blame pages.
> 
> Signed-off-by: Juergen Kreileder <jk@blackdown.de>
> ---
>  gitweb/gitweb.perl |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 4f0c3bd..c863afe 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -6107,7 +6107,9 @@ sub git_blame_common {
>  			-type=>"text/plain", -charset => "utf-8",
>  			-status=> "200 OK");
>  		local $| = 1; # output autoflush
> -		print while <$fd>;
> +		while (my $line = <$fd>) {
> +			print to_utf8($line);
> +		}
>  		close $fd
>  			or print "ERROR $!\n";
> 
> -- 
Thanks.  ACK.

BTW. all those troubles with not forgetting to call to_utf8() make me wonder if we wouldn't be better to forget about supporting $fallback_encoding and just put

  use open qw(:encoding(UTF-8) :std); 
at the beginning of gitweb, c.f. http://training.perl.com/OSCON2011/index.html
Or
  use open qw(:utf8 :std); 
though then we simply discard errors.
-- 
Jakub Narębski

← back to recent threads