Skip Menu |

This queue is for tickets about the PGP-Mail CPAN distribution.

Report information
The Basics
Id: 20110
Status: open
Priority: 0/
Queue: PGP-Mail

People
Owner: Nobody in particular
Requestors: pawal [...] blipp.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.7
Fixed in: (no value)



Subject: Support for other character sets
When using other charactersets than us-ascii or latin-1, for example UTF-8, PGP::Mail didn't translate the $pgp->{data} to the correct character set. I do this in this provided patch using Encode::decode. Please add to the distribution, since I really need support for UTF-8.
Subject: Mail.pm.utf8.patch
--- ../PGP-Mail-1.7.orig/Mail.pm 2004-01-26 15:46:09.000000000 +0100 +++ Mail.pm 2006-06-26 15:10:48.000000000 +0200 @@ -6,6 +6,7 @@ use IO::Handle; use GnuPG::Interface; use MIME::Parser; +use Encode; =head1 NAME @@ -115,6 +116,9 @@ } } + # our default charset + $self->{charset}='us-ascii'; + # we should now have the header in @header and the body # in @lines @@ -128,6 +132,12 @@ } } } + if($header=~/^content-type:\s+(\S+\/\S+)(;.*)?$/si) { + if ($header=~/charset=([a-z0-9-]+)/si) + { + $self->{charset}=$1; + } + } } if(!$self->{PGPMIME}) { @@ -183,6 +193,7 @@ close $input; $self->{data}=join "",<$output>; + $self->{data}=decode($self->{charset},$self->{data}); close $output; $self->get_status($status); @@ -202,6 +213,9 @@ $self->{status}="bad"; $self->{keyid}="0x$1"; } + elsif ($line =~ /^\[GNUPG:\] VALIDSIG (\w+) /) { + $self->{status}="good"; + } } } @@ -214,6 +228,12 @@ my $sigdata=""; my $signature=""; for my $line (@$data) { + if($line=~/^content-type:\s+(\S+\/\S+)(;.*)?$/si) { + if ($line=~/charset=([a-z0-9-]+)/si) + { + $self->{charset} = $1; + } + } if($state eq "before" && $line eq "--$bound\n") { $state="data"; @@ -282,6 +302,7 @@ $parser=new MIME::Parser; $parser->output_to_core(1); $self->{data}=$parser->parse_data($sigdata)->bodyhandle->as_string; + $self->{data}=decode($self->{charset},$self->{data}); $self->get_status($status);
Subject: Re: [rt.cpan.org #20110] Support for other character sets
Date: Mon, 26 Jun 2006 14:57:22 +0100
To: Guest via RT <bug-PGP-Mail [...] rt.cpan.org>
From: Matthew Byng-Maddick <mbm [...] colondot.net>
On Mon, Jun 26, 2006 at 09:14:42AM -0400, Guest via RT wrote: Show quoted text
> When using other charactersets than us-ascii or latin-1, for example > UTF-8, PGP::Mail didn't translate the $pgp->{data} to the correct > character set. I do this in this provided patch using Encode::decode. > Please add to the distribution, since I really need support for UTF-8.
Will do. I feel this is rather more important than the previous traffic on this ticket. Cheers MBM
Subject: Re: [rt.cpan.org #20110] Support for other character sets
Date: Tue, 27 Jun 2006 08:45:40 +0100
To: Guest via RT <bug-PGP-Mail [...] rt.cpan.org>
From: Matthew Byng-Maddick <mbm [...] colondot.net>
On Mon, Jun 26, 2006 at 09:14:42AM -0400, Guest via RT wrote: Show quoted text
> When using other charactersets than us-ascii or latin-1, for example > UTF-8, PGP::Mail didn't translate the $pgp->{data} to the correct > character set. I do this in this provided patch using Encode::decode. > Please add to the distribution, since I really need support for UTF-8.
I've been looking at this patch. I'm not entirely happy with certain aspects of it. What you've done is fine for the PGPTEXT emails, and I've been working on fitting it in how I think it should be done, but within the PGP/MIME, the Content-Type (and charset) is set within each MIME object. Consider, for example, the following MIME object: multipart/signed;protocol=application/pgp-signature; | boundary="foobar";micalg=pgp-sha1 | +-> multipart/alternative;boundary="bazqux" | | | +-> text/html;charset=utf-8 | | | +-> text/plain;charset=us-ascii | +-> application/pgp-signature; name=PGP.sig your patch, as it stands will take the us-ascii bit - which isn't really great. To be honest, the whole handling of this situation by PGP::MIME is a bit useless, and what I should probably do is provide a new interface which turns the pgp-text into a text/plain MIME container which you handle how you need to. Your patch also breaks down if there is a match for "content-type: ..." at the beginning of a line in the body, which is definitely not good - as I've merged it, I've used the MIME::Entity to get that information, but thinking about the structure above, I'm still not happy. I don't want to release until I've written a test for it, I'm afraid, so I'll have to do that at some point. I possibly won't have time until Friday or Saturday now, but I'll see what I can do. Cheers MBM
Subject: Re: [rt.cpan.org #20110] Support for other character sets
Date: Tue, 27 Jun 2006 10:30:59 +0200
To: Matthew Byng-Maddick via RT <bug-PGP-Mail [...] rt.cpan.org>
From: Patrik Wallstrom <pawal [...] blipp.com>
On Tue, 27 Jun 2006, Matthew Byng-Maddick via RT wrote: Show quoted text
> I don't want to release until I've written a test for it, I'm afraid, so > I'll have to do that at some point. I possibly won't have time until Friday > or Saturday now, but I'll see what I can do.
I didn't think of more complex MIME scenarios when I wrote the patch, it worked fine for me. But I agree with you on that there should be a proper solution that handles the more complex scenarios as well. -- patrik_wallstrom->foodfight->pawal@blipp.com->+46-733173956