]> git.donarmstrong.com Git - debbugs.git/commitdiff
use Text::Iconv instead of decode($charset,$data)
authorDon Armstrong <don@donarmstrong.com>
Thu, 6 Sep 2012 18:28:11 +0000 (11:28 -0700)
committerDon Armstrong <don@donarmstrong.com>
Thu, 6 Sep 2012 18:28:11 +0000 (11:28 -0700)
Debbugs/MIME.pm
debian/control

index 481be7bf9573f758ff331292b8f5a61fe66b75a6..9073df1069b81ccb758a81ca90bd0feef75e458b 100644 (file)
@@ -58,6 +58,7 @@ use List::MoreUtils qw(apply);
 # for decode_rfc1522
 use MIME::WordDecoder qw();
 use Encode qw(decode encode encode_utf8 decode_utf8 is_utf8);
+use Text::Iconv;
 
 # for encode_rfc1522
 use MIME::Words qw();
@@ -235,10 +236,14 @@ sub convert_to_utf8 {
      my ($data, $charset) = @_;
      # raw data just gets returned (that's the charset WordDecorder
      # uses when it doesn't know what to do)
+     return $data if not defined $data;
      return $data if $charset eq 'raw' or is_utf8($data,1);
      my $result;
      eval {
-        $result = decode($charset,$data);
+        my $converter = Text::Iconv->new($charset,"utf-8") or
+            die "Unable to create converter for charset '$charset'";
+        $result = decode_utf8($converter->convert($data));
+        die "Error while converting" if not defined $converter->retval() or not defined $result;
      };
      if ($@) {
          warn "Unable to decode charset; '$charset' and '$data': $@";
index ee365efdecc5ec36077ec06b9d346143286c94a9..8d1432898d6240b79fece0e7f7243fefd4aa7fd5 100644 (file)
@@ -13,7 +13,7 @@ Build-Depends-Indep: libparams-validate-perl,
  libhttp-server-simple-perl, libtest-www-mechanize-perl,
  libmail-rfc822-address-perl, libsafe-hole-perl, libuser-perl,
  libconfig-simple-perl, libtest-pod-perl, liblist-moreutils-perl,
- libtext-template-perl
+ libtext-template-perl, libtext-iconv-perl
 Homepage: http://wiki.debian.org/Teams/Debbugs
 
 Package: debbugs
@@ -39,7 +39,7 @@ Depends: ${perl:Depends}, libmailtools-perl, ed, libmime-tools-perl,
  libio-stringy-perl, libmldbm-perl, liburi-perl, libsoap-lite-perl,
  libcgi-simple-perl, libparams-validate-perl, libtext-template-perl,
  libsafe-hole-perl, libmail-rfc822-address-perl, liblist-moreutils-perl,
- libtext-template-perl
+ libtext-template-perl, libtext-iconv-perl
 Section: perl
 Description: modules used by the active Debian BTS
  Debian has a bug tracking system which files details of bugs reported by