[rt-devel] RT 3.0.3rc2
Dmitry Sivachenko
mitya at cavia.pp.ru
Thu Jun 19 05:18:21 EDT 2003
On Thu, Jun 19, 2003 at 04:44:58PM +0800, Autrijus Tang wrote:
> On Thu, Jun 19, 2003 at 12:11:48PM +0400, Dmitry Sivachenko wrote:
> > 1) When I am sending http://mitya.pp.ru/rt-bad-email1.dat, the following
> > appears in the maillog:
>
> That mail has the extremely evil header:
>
> From: =?UNKNOWN?Q?=C8=ED=F2=E5=F0=ED=E5=F2_=EC=E0=F0=EA=E5=F2=E8=ED=E3?=
>
> and RT simply does not know how to handle this encoding.
Your patch did solve the problem to rt-bad-email1.dat.
Thank you!
The problem with rt-bad-email2.dat remains.
>
> I have committed the patch below into my branch which takes care of
> this case by applying the same _GuessCharset routine to MIME words.
>
> As for your second problem, I can't duplicate it -- but maybe you'd
> like to check your @EmailOutputEncoding?
>
> Thanks,
> /Autrijus/
>
> --- //depot/RT/rt/lib/RT/I18N.pm 2003/06/19 08:03:42
> +++ //depot/RT/rt/lib/RT/I18N.pm 2003/06/19 08:34:19
> @@ -273,7 +273,11 @@
> # now we have got a decoded subject, try to convert into
> # utf-8 encoding
> unless ($charset =~ m/utf-8/i) {
> - Encode::from_to($enc_str, $charset, "utf8");
> + eval { Encode::from_to($enc_str, $charset, "utf8") };
> + if ($@) {
> + $charset = _GuessCharset( $enc_str );
> + Encode::from_to($enc_str, $charset, "utf8");
> + }
> }
>
> $str .= $prefix . $enc_str . $trailing;
> @@ -296,17 +300,33 @@
> sub _FindOrGuessCharset {
> my $entity = shift;
> my $head = $entity->head;
> - my $charset;
> - my $fallback = 'iso-8859-1';
>
> - return $charset if ($charset = $head->mime_attr("content-type.charset"));
> + if ($head->mime_attr("content-type.charset")) {
> + return $head->mime_attr("content-type.charset");
> + }
>
> my $body = $entity->bodyhandle or return;
> - return 'utf-8' if Encode::is_utf8( $body->as_string );
> + return _GuessCharset( $head->as_string . $body->as_string );
> +}
> +
> +# }}}
> +
> +
> +# {{{ _GuessCharset
> +
> +=head2 _GuessCharset STRING
> +
> +use Encode::Guess to try to figure it out the string's encoding.
> +
> +=cut
> +
> +sub _GuessCharset {
> + my $fallback = 'iso-8859-1';
> + my $charset;
>
> if ( @RT::EmailInputEncodings and eval { require Encode::Guess; 1 } ) {
> Encode::Guess->set_suspects(@RT::EmailInputEncodings);
> - my $decoder = Encode::Guess->guess( $head->as_string . $body->as_string );
> + my $decoder = Encode::Guess->guess( $_[0] );
>
> if ( ref $decoder ) {
> $charset = $decoder->name;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://pallas.eruditorum.org/pipermail/rt-devel/attachments/20030619/c89535cf/attachment.pgp
More information about the Rt-devel
mailing list