Browse Source

dpkg-genchanges: correctly truncate descriptions with multibyte characters

Ensure the scalar used to truncate the description is character-based
and not byte-based. But switch it back to a byte-based scalar afterwards
to avoid bad-conversion to latin1 when output in a filehandle without
any explicit encodind.

This should really be fixed in Dpkg::Control but that would be an invasive
change at this point of the squeeze release.

Reported-by: Colin Watson <cjwatson@ubuntu.com>
Raphaël Hertzog 16 years ago
parent
commit
f42344b5fb
2 changed files with 6 additions and 1 deletions
  1. 4 0
      debian/changelog
  2. 2 1
      scripts/dpkg-genchanges.pl

+ 4 - 0
debian/changelog

@@ -9,6 +9,10 @@ dpkg (1.15.8.5) UNRELEASED; urgency=low
   * Clarify effect of “dpkg --purge” on homedir files in dpkg(1).
     Thanks to The Fungi <fungi@yuggoth.org>. Closes: #593628
 
+  [ Raphaël Hertzog ]
+  * Fix dpkg-genchanges to not split the short description in the middle of a
+    UTF8 character. Closes: #593442
+
   [ Updated programs translations ]
   * Italian (Milo Casagrande). Closes: #592953
 

+ 2 - 1
scripts/dpkg-genchanges.pl

@@ -18,6 +18,7 @@
 use strict;
 use warnings;
 
+use Encode;
 use POSIX;
 use POSIX qw(:errno_h :signal_h);
 use Dpkg;
@@ -286,7 +287,7 @@ foreach my $pkg ($control->get_packages()) {
     push @f, @{$p2f{$p}} if defined $p2f{$p};
 
     # Add description of all binary packages
-    my $desc = sprintf("%-10s - %-.65s", $p, $d);
+    my $desc = encode_utf8(sprintf("%-10s - %-.65s", $p, decode_utf8($d)));
     $desc .= " (udeb)" if $pkg_type eq "udeb";
     push @descriptions, $desc;