* gitweb highligh generate illegal char when the content had utf-8 chars
@ 2011-08-04 5:31 zzs
2011-08-04 9:11 ` Ramkumar Ramachandra
0 siblings, 1 reply; 5+ messages in thread
From: zzs @ 2011-08-04 5:31 UTC (permalink / raw)
To: git
When my C file had some utf-8 comments, gitweb highlight generate
illegal chars.
So I hacked gitweb.cgi, like this:
---------------------------
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index dab89f2..48def38 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -6465,7 +6465,7 @@ sub git_blob {
$nr++;
$line = untabify($line);
printf qq!<div class="pre"><a id="l%i" href="%s#l%i" class="linenr">%4i</a> %s</div>\n!,
- $nr, esc_attr(href(-replay => 1)), $nr, $nr, $syntax ? $line : esc_html($line, -nbsp=>1);
+ $nr, esc_attr(href(-replay => 1)), $nr, $nr, $syntax ? to_utf8($line) : esc_html($line, -nbsp=>1);
}
}
close $fd
---------------------------
And it works.
But I wonder is this the rigtht solution.
Anybody help me?
--
Best Regards
zzs
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: gitweb highligh generate illegal char when the content had utf-8 chars
2011-08-04 5:31 gitweb highligh generate illegal char when the content had utf-8 chars zzs
@ 2011-08-04 9:11 ` Ramkumar Ramachandra
2011-08-04 9:39 ` Jakub Narębski
0 siblings, 1 reply; 5+ messages in thread
From: Ramkumar Ramachandra @ 2011-08-04 9:11 UTC (permalink / raw)
To: zzs; +Cc: git, Jakub Narebski
Hi,
zzs writes:
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index dab89f2..48def38 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -6465,7 +6465,7 @@ sub git_blob {
> $nr++;
> $line = untabify($line);
> printf qq!<div class="pre"><a id="l%i" href="%s#l%i" class="linenr">%4i</a> %s</div>\n!,
> - $nr, esc_attr(href(-replay => 1)), $nr, $nr, $syntax ? $line : esc_html($line, -nbsp=>1);
> + $nr, esc_attr(href(-replay => 1)), $nr, $nr, $syntax ? to_utf8($line) : esc_html($line, -nbsp=>1);
> }
> }
> close $fd
Looks sane, but I don't know enough about Gitweb to comment.
+CC: Jakub, who can probably say more.
Thanks.
-- Ram
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: gitweb highligh generate illegal char when the content had utf-8 chars
2011-08-04 9:11 ` Ramkumar Ramachandra
@ 2011-08-04 9:39 ` Jakub Narębski
2011-08-04 10:05 ` Ramkumar Ramachandra
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Narębski @ 2011-08-04 9:39 UTC (permalink / raw)
To: Ramkumar Ramachandra; +Cc: zzs, git
On Thu, Aug 4, 2011 at 11:11 AM, Ramkumar Ramachandra
<artagnon@gmail.com> wrote:
> zzs writes:
>> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
>> index dab89f2..48def38 100755
>> --- a/gitweb/gitweb.perl
>> +++ b/gitweb/gitweb.perl
>> @@ -6465,7 +6465,7 @@ sub git_blob {
>> $nr++;
>> $line = untabify($line);
>> printf qq!<div class="pre"><a id="l%i" href="%s#l%i" class="linenr">%4i</a> %s</div>\n!,
>> - $nr, esc_attr(href(-replay => 1)), $nr, $nr, $syntax ? $line : esc_html($line, -nbsp=>1);
>> + $nr, esc_attr(href(-replay => 1)), $nr, $nr, $syntax ? to_utf8($line) : esc_html($line, -nbsp=>1);
>> }
>> }
>> close $fd
>
> Looks sane, but I don't know enough about Gitweb to comment.
> +CC: Jakub, who can probably say more.
This looks correct.
--
Jakub Narebski
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: gitweb highligh generate illegal char when the content had utf-8 chars
2011-08-04 9:39 ` Jakub Narębski
@ 2011-08-04 10:05 ` Ramkumar Ramachandra
2011-08-04 15:52 ` [PATCH] fix gitweb syntax highlight utf-8 encode bug zzs
0 siblings, 1 reply; 5+ messages in thread
From: Ramkumar Ramachandra @ 2011-08-04 10:05 UTC (permalink / raw)
To: zzs; +Cc: git, Jakub Narębski
Hi,
Jakub Narębski writes:
> This looks correct.
Thanks Jakub.
>> zzs writes:
>>> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
>>> index dab89f2..48def38 100755
Please submit a nicely formatted patch with proper signoff so that we
can consider this for inclusion. Refer to
Documentation/SubmittingPatches for more details.
Thanks.
-- Ram
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] fix gitweb syntax highlight utf-8 encode bug
2011-08-04 10:05 ` Ramkumar Ramachandra
@ 2011-08-04 15:52 ` zzs
0 siblings, 0 replies; 5+ messages in thread
From: zzs @ 2011-08-04 15:52 UTC (permalink / raw)
To: artagnon; +Cc: git, 张忠山
From: 张忠山 <zzs213@126.com>
Signed-off-by: 张忠山 <zzs213@126.com>
---
gitweb/gitweb.perl | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index dab89f2..48def38 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -6465,7 +6465,7 @@ sub git_blob {
$nr++;
$line = untabify($line);
printf qq!<div class="pre"><a id="l%i" href="%s#l%i" class="linenr">%4i</a> %s</div>\n!,
- $nr, esc_attr(href(-replay => 1)), $nr, $nr, $syntax ? $line : esc_html($line, -nbsp=>1);
+ $nr, esc_attr(href(-replay => 1)), $nr, $nr, $syntax ? to_utf8($line) : esc_html($line, -nbsp=>1);
}
}
close $fd
--
1.7.4.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-08-04 16:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-04 5:31 gitweb highligh generate illegal char when the content had utf-8 chars zzs
2011-08-04 9:11 ` Ramkumar Ramachandra
2011-08-04 9:39 ` Jakub Narębski
2011-08-04 10:05 ` Ramkumar Ramachandra
2011-08-04 15:52 ` [PATCH] fix gitweb syntax highlight utf-8 encode bug zzs
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).