Bug#461167: libpdf-api2-perl: $pdf->info() metadata improperly handles Unicode strings

Chris Adams cadams at salk.edu
Thu Jan 17 01:31:50 UTC 2008


Package: libpdf-api2-perl
Version: 0.57-1
Severity: normal
Tags: patch l10n


PDF::API2 includes Encode but doesn't use it when checking for UTF-16
strings in metadata ($pdf->info() hash). This causes the output to be
garbled in our UTF-8 (perl -CSD) environment. The attached patch uses
Encode::detect to decode UTF-16BE/LE strings; it might be useful to
simply Encode::Guess the values but this approach is more conservative.

-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (990, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-5-686
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages libpdf-api2-perl depends on:
ii  libcompress-zlib-perl       1.42-2       Perl module for creation and manip
ii  perl                        5.8.8-7etch1 Larry Wall's Practical Extraction 

libpdf-api2-perl recommends no packages.

-- debconf-show failed
-------------- next part --------------
--- /usr/share/perl5/PDF/API2.pm	2006-10-04 16:55:53.000000000 -0700
+++ /tmp/API2.pm	2008-01-16 17:23:05.000000000 -0800
@@ -590,12 +590,8 @@
       foreach my $k (@{$self->{infoMeta}}) {
         next unless(defined $self->{pdf}->{'Info'}->{$k});
         $opt{$k}=$self->{pdf}->{'Info'}->{$k}->val;
-        if(unpack('n',$opt{$k})==0xfffe) {
-            my ($mark, at c)=unpack('n*',$opt{$k});
-            $opt{$k}=pack('U*', at c);
-        } elsif(unpack('n',$opt{$k})==0xfeff) {
-            my ($mark, at c)=unpack('v*',$opt{$k});
-            $opt{$k}=pack('U*', at c);
+        if ((unpack('n',$opt{$k})==0xfffe) or (unpack('n',$opt{$k})==0xfeff)) {
+            $opt{$k} = decode('UTF-16', $self->{pdf}->{'Info'}->{$k}->val);
         }
       }
   }


More information about the pkg-perl-maintainers mailing list