git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitweb: Fix chop_str not to cut in middle of utf8 multibyte chars.
@ 2008-05-20 20:55 Anders Waldenborg
  2008-05-20 22:19 ` Jakub Narebski
  0 siblings, 1 reply; 6+ messages in thread
From: Anders Waldenborg @ 2008-05-20 20:55 UTC (permalink / raw)
  To: git


Without this fix at least author name in short log may cut in middle of a
multibyte char. When the result comes to esc_html to_utf8 is called again,
which doesn't find valid utf8 and decodes using $fallback_encoding making
it even worse.

Signed-off-by: Anders Waldenborg <anders@0x63.nu>
---
  gitweb/gitweb.perl |    4 ++++
  1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 2facf2d..8308e22 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -866,6 +866,10 @@ sub chop_str {
         my $add_len = shift || 10;
         my $where = shift || 'right'; # 'left' | 'center' | 'right'

+       # Make sure perl knows it is utf8 encoded so we don't
+       # cut in the middle of a utf8 multibyte char.
+       $str = to_utf8($str);
+
         # allow only $len chars, but don't cut a word if it would fit in $add_len
         # if it doesn't fit, cut it if it's still longer than the dots we would add
         # remove chopped character entities entirely

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-05-24 13:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-20 20:55 [PATCH] gitweb: Fix chop_str not to cut in middle of utf8 multibyte chars Anders Waldenborg
2008-05-20 22:19 ` Jakub Narebski
2008-05-21  7:27   ` Junio C Hamano
2008-05-21  7:45     ` Anders Waldenborg
2008-05-24 13:34       ` Jakub Narebski
2008-05-21 11:44   ` [PATCH] gitweb: Convert string to internal form before chopping in chop_str Anders Waldenborg

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).