[rt-users] Re: [rt-devel] Patch for RT 3.0.3 attachment conversion problem

Autrijus Tang autrijus at autrijus.org
Wed Jun 25 10:11:48 EDT 2003


On Wed, Jun 25, 2003 at 03:55:49PM +0200, Remy Chibois wrote:
> The following patch seems to correct the problem and works for my setup.
> Can you please give it a try ?

This patch seems flawed in the sense that it breaks I18N.pm's 
capability of correctly handling high bits in non-text/plain
attachment's file names.

I have instrumented my I18N.pm with debug statements (attached
as I18N.diff) and feed your test case into it:

    Subject: Re: [MI #03760] eMail Bild-Anhang ist futsch

the log is shown in attached rt.log, and I can view the ticket
and bild.pdf without problem there.

I also cannot produce the UTF32LE problem here... It is probably
a wrong thing to do if people somehow set it into @EmailInputEncodings.

Anyway, I'd like you (and others who notice this problem) to
try I18N.diff and see what it comes out, so we can determine
whether it's db-specific, mta-specific, or what.

Thanks,
/Autrijus/
-------------- next part --------------
XXX: We are handed a multipart (MIME::Entity=HASH(0x91668fc)), recursing into it... (/opt/rt3/lib/RT/I18N.pm:161)
XXX: Trying to guess encoding of MIME::Entity=HASH(0x9169c78)... (/opt/rt3/lib/RT/I18N.pm:166)
XXX: MIME::Entity=HASH(0x9169c78) is encoded in iso-8859-1. Now set Head to it... (/opt/rt3/lib/RT/I18N.pm:172)
XXX: So. Let's see if text/plain is the type of MIME::Entity=HASH(0x9169c78) (text/plain). (/opt/rt3/lib/RT/I18N.pm:186)
XXX: It is. Continuing decoding MIME::Entity=HASH(0x9169c78)... (/opt/rt3/lib/RT/I18N.pm:188)
[Wed Jun 25 14:02:39 2003] [debug]: Converting 'iso-8859-1' to 'utf-8' (/opt/rt3/lib/RT/I18N.pm:197)
XXX: Trying to guess encoding of MIME::Entity=HASH(0x916d9ec)... (/opt/rt3/lib/RT/I18N.pm:166)
[Wed Jun 25 14:02:40 2003] [warning]: Encode::Guess failed: No appropriate encodings found!; fallback to iso-8859-1 (/opt/rt3/lib/RT/I18N.pm:356)
XXX: MIME::Entity=HASH(0x916d9ec) is encoded in iso-8859-1. Now set Head to it... (/opt/rt3/lib/RT/I18N.pm:172)
XXX: MIME::Entity=HASH(0x916d9ec) has content-type.name set to bild.pdf, de-wording it... (/opt/rt3/lib/RT/I18N.pm:180)
XXX: ... now MIME::Entity=HASH(0x916d9ec) has content-type.name set to bild.pdf (/opt/rt3/lib/RT/I18N.pm:182)
XXX: MIME::Entity=HASH(0x916d9ec) has content-disposition.filename set to bild.pdf, de-wording it... (/opt/rt3/lib/RT/I18N.pm:180)
XXX: ... now MIME::Entity=HASH(0x916d9ec) has content-disposition.filename set to bild.pdf (/opt/rt3/lib/RT/I18N.pm:182)
XXX: So. Let's see if text/plain is the type of MIME::Entity=HASH(0x916d9ec) (application/pdf). (/opt/rt3/lib/RT/I18N.pm:186)
XXX: ...and we're back from the multipart (MIME::Entity=HASH(0x91668fc))... (/opt/rt3/lib/RT/I18N.pm:163)
XXX: Trying to guess encoding of MIME::Entity=HASH(0x91668fc)... (/opt/rt3/lib/RT/I18N.pm:166)
[Wed Jun 25 14:02:41 2003] [info]: <rt-3.0.3-35-104.1.7697843596742 at example.com> #35/104 - Scrip 2  (/opt/rt3/lib/RT/Action/SendEmail.pm:90)
XXX: Trying to guess encoding of MIME::Entity=HASH(0x9306a4c)... (/opt/rt3/lib/RT/I18N.pm:166)
XXX: MIME::Entity=HASH(0x9306a4c) is encoded in utf-8. Now set Head to it... (/opt/rt3/lib/RT/I18N.pm:172)
XXX: So. Let's see if text/plain is the type of MIME::Entity=HASH(0x9306a4c) (text/plain). (/opt/rt3/lib/RT/I18N.pm:186)
XXX: It is. Continuing decoding MIME::Entity=HASH(0x9306a4c)... (/opt/rt3/lib/RT/I18N.pm:188)
[Wed Jun 25 14:02:41 2003] [info]: <rt-3.0.3-35-104.1.7697843596742 at example.com>
 No recipients found. Not sending.
 (/opt/rt3/lib/RT/Action/SendEmail.pm:250)
-------------- next part --------------
==== //depot/RT/rt/lib/RT/I18N.pm#72 - /home/autrijus/depot/RT/rt/lib/RT/I18N.pm ====
@@ -158,14 +158,18 @@
     my ( $entity, $enc ) = ( shift, shift );
 
     if ( $entity->is_multipart ) {
+	$RT::Logger->info("XXX: We are handed a multipart ($entity), recursing into it...");
 	SetMIMEEntityToEncoding( $_, $enc ) foreach $entity->parts;
+	$RT::Logger->info("XXX: ...and we're back from the multipart ($entity)...");
     }
 
+    $RT::Logger->info("XXX: Trying to guess encoding of $entity...");
     my $charset = _FindOrGuessCharset($entity) or return;
     # one and only normalization
     $charset = 'utf-8' if $charset eq 'utf8';
     $enc     = 'utf-8' if $enc     eq 'utf8';
 
+    $RT::Logger->info("XXX: $entity is encoded in $charset. Now set Head to it...");
     SetMIMEHeadToEncoding($entity->head, $charset => $enc);
 
     my $head = $entity->head;
@@ -173,11 +177,15 @@
     # convert at least MIME word encoded attachment filename
     foreach my $attr (qw(content-type.name content-disposition.filename)) {
 	if ( my $name = $head->mime_attr($attr) ) {
+	    $RT::Logger->info("XXX: $entity has $attr set to $name, de-wording it...");
 	    $head->mime_attr( $attr => DecodeMIMEWordsToUTF8($name) );
+	    $RT::Logger->info("XXX: ... now $entity has $attr set to " . $head->mime_attr($attr));
 	}
     }
 
+    $RT::Logger->info("XXX: So. Let's see if text/plain is the type of $entity (" . $head->mime_type . ").");
     return unless ( $head->mime_type =~ /^text\/plain$/i );
+    $RT::Logger->info("XXX: It is. Continuing decoding $entity...");
 
     my $body = $entity->bodyhandle;
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20030625/4408a286/attachment.sig>


More information about the rt-users mailing list