[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.7-200-g224c3a3
jesse
jesse at bestpractical.com
Fri Mar 12 07:48:31 EST 2010
The branch, 3.8-trunk has been updated
via 224c3a3cb17e663cbf371a6f1c4a4c25e059b6c2 (commit)
from b81e7683b4ad86ba5a52b40595b672d516311310 (commit)
Summary of changes:
lib/RT/I18N.pm | 47 +++++++++++++++++++++++------------------------
1 files changed, 23 insertions(+), 24 deletions(-)
- Log -----------------------------------------------------------------
commit 224c3a3cb17e663cbf371a6f1c4a4c25e059b6c2
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Fri Mar 12 13:47:28 2010 +0100
I18N was transcoding attachments to utf8 one line at a time. This
doesn't work at all for UTF16 and just generally seems crazy.
diff --git a/lib/RT/I18N.pm b/lib/RT/I18N.pm
index ac41b2c..aa13c67 100755
--- a/lib/RT/I18N.pm
+++ b/lib/RT/I18N.pm
@@ -223,34 +223,33 @@ sub SetMIMEEntityToEncoding {
my $body = $entity->bodyhandle;
- if ( $enc ne $charset && $body) {
- my @lines = $body->as_lines or return;
-
- # {{{ Convert the body
- eval {
- $RT::Logger->debug("Converting '$charset' to '$enc' for ". $head->mime_type . " - ". ($head->get('subject') || 'Subjectless message'));
-
- # NOTE:: see the comments at the end of the sub.
- Encode::_utf8_off( $lines[$_] ) foreach ( 0 .. $#lines );
- Encode::from_to( $lines[$_], $charset => $enc ) for ( 0 .. $#lines );
- };
-
- if ($@) {
- $RT::Logger->error( "Encoding error: " . $@ . " defaulting to ISO-8859-1 -> UTF-8" );
- eval {
- Encode::from_to( $lines[$_], 'iso-8859-1' => $enc ) foreach ( 0 .. $#lines );
- };
- if ($@) {
- $RT::Logger->crit( "Totally failed to convert to utf-8: " . $@ . " I give up" );
- }
- }
- # }}}
+ if ( $enc ne $charset && $body ) {
+ my $string = $body->as_string or return;
+
+ # {{{ Convert the body
+ eval {
+ $RT::Logger->debug( "Converting '$charset' to '$enc' for " . $head->mime_type . " - " . ( $head->get('subject') || 'Subjectless message' ) );
+
+ # NOTE:: see the comments at the end of the sub.
+ Encode::_utf8_off( $string);
+ Encode::from_to( $string, $charset => $enc );
+ };
+
+ if ($@) {
+ $RT::Logger->error( "Encoding error: " . $@ . " defaulting to ISO-8859-1 -> UTF-8" );
+ eval { Encode::from_to( $string, 'iso-8859-1' => $enc ) };
+ if ($@) {
+ $RT::Logger->crit( "Totally failed to convert to utf-8: " . $@ . " I give up" );
+ }
+ }
+
+ # }}}
- my $new_body = MIME::Body::InCore->new( \@lines );
+ my $new_body = MIME::Body::InCore->new( $string);
# set up the new entity
$head->mime_attr( "content-type" => 'text/plain' )
- unless ( $head->mime_attr("content-type") );
+ unless ( $head->mime_attr("content-type") );
$head->mime_attr( "content-type.charset" => $enc );
$entity->bodyhandle($new_body);
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list