[Rt-commit] rt branch, 4.0-trunk, updated. rt-4.0.1-263-g88fe4cd
Alex Vandiver
alexmv at bestpractical.com
Thu Aug 4 20:22:03 EDT 2011
The branch, 4.0-trunk has been updated
via 88fe4cda74fef7a79333ec0f843d9e781fe7bac4 (commit)
via 1fa76238bf522984d0d8afad3b13b44492961d79 (commit)
via dbb313915c65f1d24e36f4defa02311e30da7a10 (commit)
via 89332a9567d2bd07882df55cc7d77956cfc57143 (commit)
via 96434ce0de13a7a6d2858b2696d6b8bc6bacf4a8 (commit)
via edd07b4279610bd45becc761581edfb39f0c4a05 (commit)
via 6e18d872b061e1f07c9f00875ab5ad78a71448c6 (commit)
via 50b71988c792997a74994936c078f96c15ecb80f (commit)
via e1675b1031c2d3e9d2bba444547929134c8e10ab (commit)
via cd653d8cd9b28b4fec9d58d2b42dd752def8a964 (commit)
via e5b1ebaae29cb810cefc1a14fc30511eacc0a072 (commit)
via 4b264c9a632ec3a9916e51afabe0472ecde9a888 (commit)
via 5f6509da75d9845536b9faafe1adbbfaec236fbe (commit)
via ccafbd233e4f50bd8ef1889949e91dc6190f495b (commit)
via 1a12831804477b5cdbf91bcbf7169cd7e31ada52 (commit)
via 8087bb0aece69c0c7e358b5ffcc3ab4b5cf769ec (commit)
via e352eb978850609274f22d35508a733f3bd54519 (commit)
via 6415231f10fb8672da23a1eda97eef403723c5e8 (commit)
from f75bbeab6f3ab55e544edc5abda078d421b58fc0 (commit)
Summary of changes:
lib/RT/Approval/Rule/Created.pm | 2 +
lib/RT/Approval/Rule/NewPending.pm | 2 +
lib/RT/Approval/Rule/Passed.pm | 23 +++++--
lib/RT/Approval/Rule/Rejected.pm | 25 +++++---
lib/RT/I18N.pm | 90 +++------------------------
share/html/Ticket/Elements/ShowTransaction | 14 ++++
t/mail/sendmail.t | 34 +++++++---
t/mail/wrong_mime_charset.t | 17 +++--
8 files changed, 95 insertions(+), 112 deletions(-)
- Log -----------------------------------------------------------------
commit 88fe4cda74fef7a79333ec0f843d9e781fe7bac4
Merge: f75bbea 1fa7623
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu Aug 4 19:43:23 2011 -0400
Merge branch '3.8-trunk' into 4.0-trunk
Conflicts:
lib/RT/I18N.pm
lib/RT/Ticket_Overlay.pm
lib/RT/Transaction_Overlay.pm
share/html/Search/Bulk.html
share/html/Ticket/Elements/PreviewScrips
t/mail/sendmail.t
t/mail/wrong_mime_charset.t
diff --cc lib/RT/I18N.pm
index a1f2af5,4c70922..b9c1c54
mode 100644,100755..100644
--- a/lib/RT/I18N.pm
+++ b/lib/RT/I18N.pm
@@@ -241,42 -243,17 +236,16 @@@ sub SetMIMEEntityToEncoding
if ( $enc ne $charset && $body ) {
my $string = $body->as_string or return;
+
- # {{{ Convert the body
- $RT::Logger->debug( "Converting '$charset' to '$enc' for " . $head->mime_type . " - " . ( $head->get('subject') || 'Subjectless message' ) );
++ $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::_utf8_off($string);
- my $orig_string = $string;
-
- # Convert the body
- eval {
- $RT::Logger->debug( "Converting '$charset' to '$enc' for "
- . $head->mime_type . " - "
- . ( $head->get('subject') || 'Subjectless message' ) );
- Encode::from_to( $string, $charset => $enc, Encode::FB_CROAK );
- };
-
- if ($@) {
- $RT::Logger->error( "Encoding error: "
- . $@
- . " falling back to iso-8859-1 => $enc" );
- $string = $orig_string;
- eval {
- Encode::from_to(
- $string,
- 'iso-8859-1' => $enc,
- Encode::FB_CROAK
- );
- };
- if ($@) {
- $RT::Logger->error( "Encoding error: "
- . $@
- . " forcing conversion to $charset => $enc" );
- $string = $orig_string;
- Encode::from_to( $string, $charset => $enc );
- }
- }
-
- # }}}
+ Encode::from_to( $string, $charset => $enc );
- # }}}
-
- my $new_body = MIME::Body::InCore->new( $string);
+ my $new_body = MIME::Body::InCore->new($string);
# set up the new entity
$head->mime_attr( "content-type" => 'text/plain' )
@@@ -384,37 -357,6 +347,27 @@@ sub DecodeMIMEWordsToEncoding
$str .= $prefix . $enc_str . $trailing;
}
+ }
+
+# handle filename*=ISO-8859-1''%74%E9%73%74%2E%74%78%74, see also rfc 2231
+ @list = $str =~ m/(.*?\*=)([^']*?)'([^']*?)'(\S+)(.*?)(?=(?:\*=|$))/gcs;
+ if (@list) {
+ $str = '';
+ while (@list) {
+ my ( $prefix, $charset, $language, $enc_str, $trailing ) =
+ splice @list, 0, 5;
+ $prefix =~ s/\*=$/=/; # remove the *
+ $enc_str =~ s/%(\w{2})/chr hex $1/eg;
+ unless ( $charset eq $to_charset ) {
- my $orig_str = $enc_str;
- local $@;
- eval {
- Encode::from_to( $enc_str, $charset, $to_charset,
- Encode::FB_CROAK );
- };
- if ($@) {
- $enc_str = $orig_str;
- $charset = _GuessCharset($enc_str);
- Encode::from_to( $enc_str, $charset, $to_charset );
- }
++ Encode::from_to( $enc_str, $charset, $to_charset );
+ }
+ $enc_str = qq{"$enc_str"}
+ if $enc_str =~ /[,;]/
+ and $enc_str !~ /^".*"$/
+ and (!$field || $field =~ /^(?:To$|From$|B?Cc$|Content-)/i);
+ $str .= $prefix . $enc_str . $trailing;
+ }
+ }
# We might have \n without trailing whitespace, which will result in
# invalid headers.
@@@ -582,32 -478,10 +535,9 @@@ sub SetMIMEHeadToEncoding
my @values = $head->get_all($tag);
$head->delete($tag);
foreach my $value (@values) {
- Encode::_utf8_off($value);
- my $orig_value = $value;
if ( $charset ne $enc ) {
- eval {
- Encode::from_to( $value, $charset => $enc, Encode::FB_CROAK );
- };
- if ($@) {
- $RT::Logger->error( "Encoding error: "
- . $@
- . " falling back to iso-8859-1 => $enc" );
- $value = $orig_value;
- eval {
- Encode::from_to(
- $value,
- 'iso-8859-1' => $enc,
- Encode::FB_CROAK
- );
- };
- if ($@) {
- $RT::Logger->error( "Encoding error: "
- . $@
- . " forcing conversion to $charset => $enc" );
- $value = $orig_value;
- Encode::from_to( $value, $charset => $enc );
- }
- }
-
+ Encode::_utf8_off($value);
+ Encode::from_to( $value, $charset => $enc );
}
$value = DecodeMIMEWordsToEncoding( $value, $enc, $tag )
unless $preserve_words;
diff --cc t/mail/sendmail.t
index 05a59bd,1f97bbb..bb5d2db
--- a/t/mail/sendmail.t
+++ b/t/mail/sendmail.t
@@@ -3,8 -3,7 +3,7 @@@
use strict;
use File::Spec ();
- use RT::Test tests => 139;
- use Test::Warn;
-use RT::Test tests => 137;
++use RT::Test tests => 141;
use RT::EmailParser;
use RT::Tickets;
@@@ -315,18 -323,8 +314,33 @@@ $parser->ParseMIMEEntityFromScalar($con
&text_html_redef_sendmessage;
%args = (message => $content, queue => 1, action => 'correspond');
- RT::Interface::Email::Gateway(\%args);
- $tickets = RT::Tickets->new($RT::SystemUser);
+
- warnings_like {
- RT::Interface::Email::Gateway(\%args);
- }
- [
- qr/Encoding error: "\\x\{041f\}" does not map to iso-8859-1 .*/,
- qr/Encoding error: "\\x\{041f\}" does not map to iso-8859-1 .*/
- ],
- "The badly formed Russian spam we have isn't actually well-formed UTF8, which makes Encode (correctly) warn";
++{
++
++my @warnings;
++local $SIG{__WARN__} = sub {
++ push @warnings, "@_";
++};
++
++RT::Interface::Email::Gateway(\%args);
+
++TODO: {
++ local $TODO =
++'need a better approach of encoding converter, should be fixed in 4.2';
++ok( @warnings == 1 || @warnings == 2, "1 or 2 warnings are ok" );
++ok( @warnings == 1 || ( @warnings == 2 && $warnings[1] eq $warnings[0] ),
++ 'if there are 2 warnings, they should be same' );
++
++like(
++ $warnings[0],
++ qr/\QEncoding error: "\x{041f}" does not map to iso-8859-1/,
++"The badly formed Russian spam we have isn't actually well-formed UTF8, which makes Encode (correctly) warn",
++);
++
++}
++}
+
+ $tickets = RT::Tickets->new(RT->SystemUser);
$tickets->OrderBy(FIELD => 'id', ORDER => 'DESC');
$tickets->Limit(FIELD => 'id' ,OPERATOR => '>', VALUE => '0');
$tick = $tickets->First();
diff --cc t/mail/wrong_mime_charset.t
index 7636de4,71a574f..511a7e6
--- a/t/mail/wrong_mime_charset.t
+++ b/t/mail/wrong_mime_charset.t
@@@ -16,29 -16,12 +16,31 @@@ my $mime = MIME::Entity->buil
# set the wrong charset mime in purpose
$mime->head->mime_attr( "Content-Type.charset" => 'utf8' );
+my @warnings;
+local $SIG{__WARN__} = sub {
+ push @warnings, "@_";
+};
+
RT::I18N::SetMIMEEntityToEncoding( $mime, 'iso-8859-1' );
+ TODO: {
+ local $TODO =
+ 'need a better approach of encoding converter, should be fixed in 4.2';
+
+# this is a weird behavior for different perl versions, 5.12 warns twice,
+# which is correct since we do the encoding thing twice, for Subject
+# and Data respectively.
+# but 5.8 and 5.10 warns only once.
+ok( @warnings == 1 || @warnings == 2, "1 or 2 warnings are ok" );
- ok(
- @warnings == 1 || $warnings[1] eq $warnings[0],
- 'if there are 2 warnings, they should be same'
- );
++ok( @warnings == 1 || ( @warnings == 2 && $warnings[1] eq $warnings[0] ),
++ 'if there are 2 warnings, they should be same' );
+
+like(
+ $warnings[0],
+ qr/\QEncoding error: "\x{fffd}" does not map to iso-8859-1/,
+"We can't encode something into the wrong encoding without Encode complaining"
+);
+
my $subject = decode( 'iso-8859-1', $mime->head->get('Subject') );
chomp $subject;
is( $subject, $test_string, 'subject is set to iso-8859-1' );
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list