X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FMIME.pm;h=481be7bf9573f758ff331292b8f5a61fe66b75a6;hb=9501bf7323cb40d0365f589fad6068dba4c48a45;hp=640627651581826bf8bcce5570d8acb46085a3ce;hpb=f960955ece8decaa8827af29bab6900b37e130bd;p=debbugs.git diff --git a/Debbugs/MIME.pm b/Debbugs/MIME.pm index 6406276..481be7b 100644 --- a/Debbugs/MIME.pm +++ b/Debbugs/MIME.pm @@ -31,12 +31,21 @@ use warnings; use strict; use base qw(Exporter); -use vars qw($VERSION @EXPORT_OK); +use vars qw($DEBUG $VERSION @EXPORT_OK %EXPORT_TAGS @EXPORT); BEGIN { $VERSION = 1.00; + $DEBUG = 0 unless defined $DEBUG; - @EXPORT_OK = qw(parse decode_rfc1522 encode_rfc1522 convert_to_utf8 create_mime_message getmailbody); + @EXPORT = (); + + %EXPORT_TAGS = (mime => [qw(parse create_mime_message getmailbody)], + rfc1522 => [qw(decode_rfc1522 encode_rfc1522)], + utf8 => [qw(convert_to_utf8)], + ); + @EXPORT_OK=(); + Exporter::export_ok_tags(keys %EXPORT_TAGS); + $EXPORT_TAGS{all} = [@EXPORT_OK]; } use File::Path; @@ -229,9 +238,7 @@ sub convert_to_utf8 { return $data if $charset eq 'raw' or is_utf8($data,1); my $result; eval { - # this encode/decode madness is to make sure that the data - # really is valid utf8 and that the is_utf8 flag is off. - $result = encode("utf8",decode($charset,$data)) + $result = decode($charset,$data); }; if ($@) { warn "Unable to decode charset; '$charset' and '$data': $@"; @@ -316,7 +323,7 @@ sub encode_rfc1522 { if (length $encoded > 75) { # Turn utf8 into the internal perl representation # so . is a character, not a byte. - my $tempstr = decode_utf8($word,Encode::FB_DEFAULT); + my $tempstr = is_utf8($word)?$word:decode_utf8($word,Encode::FB_DEFAULT); my @encoded; # Strip it into 10 character long segments, and encode # the segments