{"thread":{"id":"28019","subject":"gitweb highligh generate illegal char when the content had utf-8 chars","startedAt":"2011-08-04T05:31:23Z","lastAt":"2011-08-04T15:52:55Z","messageCount":5,"participants":["zzs","Ramkumar Ramachandra","Jakub Narębski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"172886","messageId":"20110804053123.GA13198@greatfirst.com","threadId":"28019","inReplyTo":null,"subject":"gitweb highligh generate illegal char when the content had utf-8 chars","fromName":"zzs","fromEmail":"zzs213@126.com","sentAt":"2011-08-04T05:31:23Z","receivedAt":"2011-08-04T05:31:23Z","isPatch":false,"sender":{"key":"zzs213@126.com","avatar":null},"body":"When my C file had some utf-8 comments, gitweb highlight generate\nillegal chars.\n\nSo I hacked gitweb.cgi, like this:\n\n---------------------------\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex dab89f2..48def38 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -6465,7 +6465,7 @@ sub git_blob {\n                        $nr++;\n                        $line = untabify($line);\n                        printf qq!<div class=\"pre\"><a id=\"l%i\" href=\"%s#l%i\" class=\"linenr\">%4i</a> %s</div>\\n!,\n-                              $nr, esc_attr(href(-replay => 1)), $nr, $nr, $syntax ? $line : esc_html($line, -nbsp=>1);\n+                              $nr, esc_attr(href(-replay => 1)), $nr, $nr, $syntax ? to_utf8($line) : esc_html($line, -nbsp=>1);\n                }\n        }\n        close $fd\n---------------------------\n\n\nAnd it works.\n\nBut I wonder is this the rigtht solution.\n\nAnybody help me?\n\n-- \nBest Regards\nzzs\n"},{"id":"172893","messageId":"CALkWK0kURz_Rax-JOPT2sW1x4VrqWk=KDjUzzw4apacDo1UTyg@mail.gmail.com","threadId":"28019","inReplyTo":"20110804053123.GA13198@greatfirst.com","subject":"Re: gitweb highligh generate illegal char when the content had utf-8 chars","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2011-08-04T09:11:26Z","receivedAt":"2011-08-04T09:11:26Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi,\n\nzzs writes:\n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index dab89f2..48def38 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -6465,7 +6465,7 @@ sub git_blob {\n>                        $nr++;\n>                        $line = untabify($line);\n>                        printf qq!<div class=\"pre\"><a id=\"l%i\" href=\"%s#l%i\" class=\"linenr\">%4i</a> %s</div>\\n!,\n> -                              $nr, esc_attr(href(-replay => 1)), $nr, $nr, $syntax ? $line : esc_html($line, -nbsp=>1);\n> +                              $nr, esc_attr(href(-replay => 1)), $nr, $nr, $syntax ? to_utf8($line) : esc_html($line, -nbsp=>1);\n>                }\n>        }\n>        close $fd\n\nLooks sane, but I don't know enough about Gitweb to comment.\n+CC: Jakub, who can probably say more.\n\nThanks.\n\n-- Ram\n"},{"id":"172897","messageId":"CANQwDwcR5sS3-m6SifQbjU1VoS5bxRRGJNZZj0U+zp=zsoGbLA@mail.gmail.com","threadId":"28019","inReplyTo":"CALkWK0kURz_Rax-JOPT2sW1x4VrqWk=KDjUzzw4apacDo1UTyg@mail.gmail.com","subject":"Re: gitweb highligh generate illegal char when the content had utf-8 chars","fromName":"Jakub Narębski","fromEmail":"jnareb@gmail.com","sentAt":"2011-08-04T09:39:37Z","receivedAt":"2011-08-04T09:39:37Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Thu, Aug 4, 2011 at 11:11 AM, Ramkumar Ramachandra\n<artagnon@gmail.com> wrote:\n> zzs writes:\n\n>> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n>> index dab89f2..48def38 100755\n>> --- a/gitweb/gitweb.perl\n>> +++ b/gitweb/gitweb.perl\n>> @@ -6465,7 +6465,7 @@ sub git_blob {\n>>                        $nr++;\n>>                        $line = untabify($line);\n>>                        printf qq!<div class=\"pre\"><a id=\"l%i\" href=\"%s#l%i\" class=\"linenr\">%4i</a> %s</div>\\n!,\n>> -                              $nr, esc_attr(href(-replay => 1)), $nr, $nr, $syntax ? $line : esc_html($line, -nbsp=>1);\n>> +                              $nr, esc_attr(href(-replay => 1)), $nr, $nr, $syntax ? to_utf8($line) : esc_html($line, -nbsp=>1);\n>>                }\n>>        }\n>>        close $fd\n>\n> Looks sane, but I don't know enough about Gitweb to comment.\n> +CC: Jakub, who can probably say more.\n\nThis looks correct.\n\n-- \nJakub Narebski\n"},{"id":"172900","messageId":"CALkWK0kOTXyevPy0Ys+pWwGjr2NSo3+ifhWuPVU+=FL=LC=J7A@mail.gmail.com","threadId":"28019","inReplyTo":"CANQwDwcR5sS3-m6SifQbjU1VoS5bxRRGJNZZj0U+zp=zsoGbLA@mail.gmail.com","subject":"Re: gitweb highligh generate illegal char when the content had utf-8 chars","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2011-08-04T10:05:41Z","receivedAt":"2011-08-04T10:05:41Z","isPatch":false,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi,\n\nJakub Narębski writes:\n> This looks correct.\n\nThanks Jakub.\n\n>> zzs writes:\n>>> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n>>> index dab89f2..48def38 100755\n\nPlease submit a nicely formatted patch with proper signoff so that we\ncan consider this for inclusion.  Refer to\nDocumentation/SubmittingPatches for more details.\n\nThanks.\n\n-- Ram\n"},{"id":"172932","messageId":"1312473175-28195-1-git-send-email-zzs213@126.com","threadId":"28019","inReplyTo":"CALkWK0kOTXyevPy0Ys+pWwGjr2NSo3+ifhWuPVU+=FL=LC=J7A@mail.gmail.com","subject":"[PATCH] fix gitweb syntax highlight utf-8 encode bug","fromName":"zzs","fromEmail":"zzs213@126.com","sentAt":"2011-08-04T15:52:55Z","receivedAt":"2011-08-04T15:52:55Z","isPatch":true,"sender":{"key":"zzs213@126.com","avatar":null},"body":"From: 张忠山 <zzs213@126.com>\n\nSigned-off-by: 张忠山 <zzs213@126.com>\n---\n gitweb/gitweb.perl |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex dab89f2..48def38 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -6465,7 +6465,7 @@ sub git_blob {\n \t\t\t$nr++;\n \t\t\t$line = untabify($line);\n \t\t\tprintf qq!<div class=\"pre\"><a id=\"l%i\" href=\"%s#l%i\" class=\"linenr\">%4i</a> %s</div>\\n!,\n-\t\t\t       $nr, esc_attr(href(-replay => 1)), $nr, $nr, $syntax ? $line : esc_html($line, -nbsp=>1);\n+\t\t\t       $nr, esc_attr(href(-replay => 1)), $nr, $nr, $syntax ? to_utf8($line) : esc_html($line, -nbsp=>1);\n \t\t}\n \t}\n \tclose $fd\n-- \n1.7.4.4\n"}]}