[Rt-commit] rt branch, 4.2-on-4.0/protect-more-chars-while-decoding-headers, updated. rt-4.0.12-22-gf428fe5
Thomas Sibley
trs at bestpractical.com
Wed May 8 19:06:38 EDT 2013
The branch, 4.2-on-4.0/protect-more-chars-while-decoding-headers has been updated
via f428fe5e8f3dad991aca31a7e7c7ec25f9bc6049 (commit)
via d5a3d74fdb50089ea44101afe74665109b086411 (commit)
via 52c44bb6d4d7e65f45026bec9a837be3419823f7 (commit)
via 6e1cfa14ec4395388b943486b38a83b5e0fae43e (commit)
via 6b2e53315d2fa2c66410a725acd4fa0e51bb2849 (commit)
via bc30f4742bf18ac28b65ec8ed0d82fbeee600cf2 (commit)
via 141986480efb94751bb80b8dd288bcb4d7fc6d7f (commit)
from 6c78d437d02f4fc55547d17cfd0aaa3a2b2e489e (commit)
Summary of changes:
t/approval/admincc.t | 1 -
t/approval/basic.t | 2 -
t/mail/header-characters.t | 10 ++--
t/mail/mime_decoding.t | 114 +++++++++++++++++++++++++--------------------
t/mail/multipart.t | 2 +-
t/web/googleish_search.t | 4 +-
6 files changed, 72 insertions(+), 61 deletions(-)
- Log -----------------------------------------------------------------
commit 141986480efb94751bb80b8dd288bcb4d7fc6d7f
Author: Thomas Sibley <trs at bestpractical.com>
Date: Wed May 8 15:36:00 2013 -0700
Tests: Adjust diagnostic descriptions to match what's actually being tested
diff --git a/t/mail/header-characters.t b/t/mail/header-characters.t
index fe06d1a..10952ea 100644
--- a/t/mail/header-characters.t
+++ b/t/mail/header-characters.t
@@ -8,7 +8,7 @@ use Encode;
my ($baseurl, $m) = RT::Test->started_ok;
-diag "Testing non-ASCII in From: header";
+diag "Testing non-ASCII latin1 in From: header";
SKIP:{
skip "Test requires Email::Address 1.893 or later, "
. "you have $Email::Address::VERSION", 3,
@@ -36,7 +36,7 @@ here's some content
}
}
-diag "Testing iso-8859-1 encoded non-ASCII in From: header";
+diag "Testing non-ASCII latin1 in From: header with MIME-word-encoded phrase";
SKIP:{
skip "Test requires Email::Address 1.893 or later, "
. "you have $Email::Address::VERSION", 3,
commit bc30f4742bf18ac28b65ec8ed0d82fbeee600cf2
Author: Thomas Sibley <trs at bestpractical.com>
Date: Wed May 8 15:42:16 2013 -0700
Tests: Correct a typo'd email address in the From: header
diff --git a/t/mail/header-characters.t b/t/mail/header-characters.t
index 10952ea..46e596e 100644
--- a/t/mail/header-characters.t
+++ b/t/mail/header-characters.t
@@ -15,7 +15,7 @@ SKIP:{
if $Email::Address::VERSION < 1.893;
my $mail = encode( 'iso-8859-1', <<'.' );
-From: René@example.com>
+From: <René@example.com>
Reply-To: =?iso-8859-1?Q?Ren=E9?= <René@example.com>
Subject: testing non-ASCII From
Content-Type: text/plain; charset=iso-8859-1
commit 6b2e53315d2fa2c66410a725acd4fa0e51bb2849
Author: Thomas Sibley <trs at bestpractical.com>
Date: Wed May 8 15:42:39 2013 -0700
Tests: Catch the new "unparseable email address" warnings
A warning is now issued for each header field instead of a single
warning for all sender fields.
diff --git a/t/mail/header-characters.t b/t/mail/header-characters.t
index 46e596e..97fdd62 100644
--- a/t/mail/header-characters.t
+++ b/t/mail/header-characters.t
@@ -25,7 +25,7 @@ here's some content
my ($status, $id);
warnings_like { ( $status, $id ) = RT::Test->send_via_mailgate($mail) }
- [qr/Failed to parse Reply-To:.*, From:/,
+ [(qr/Unable to parse an email address from/) x 2,
qr/Couldn't parse or find sender's address/
],
'Got parse error for non-ASCII in From';
@@ -53,7 +53,7 @@ here's some content
my ($status, $id);
warnings_like { ( $status, $id ) = RT::Test->send_via_mailgate($mail) }
- [qr/Failed to parse Reply-To:.*, From:/,
+ [(qr/Unable to parse an email address from/) x 2,
qr/Couldn't parse or find sender's address/
],
'Got parse error for iso-8859-1 in From';
commit 6e1cfa14ec4395388b943486b38a83b5e0fae43e
Author: Thomas Sibley <trs at bestpractical.com>
Date: Wed May 8 15:37:22 2013 -0700
Tests: Remove Requestors from approval templates
The ->Requestors method returns an RT::Group object which stringified
during template interpolation. The new email address parsing balks at
RT::Group=HASH(0xDEADBEEF), appropriately so. Providing the actual
requestor email addresses would cause autoreplies to go out and the rest
of the test assumptions to break, so simply remove the requestors all
together. Generally approval tickets don't use requestors in real use
cases anyway.
diff --git a/t/approval/admincc.t b/t/approval/admincc.t
index b439296..92b7f5f 100644
--- a/t/approval/admincc.t
+++ b/t/approval/admincc.t
@@ -42,7 +42,6 @@ Queue: ___Approvals
Type: approval
Owner: CTO
AdminCCs: COO, CEO
-Requestors: {$Tickets{"TOP"}->Requestors}
DependedOnBy: TOP
Subject: CTO Approval for PO: {$Tickets{"TOP"}->Id} - {$Tickets{"TOP"}->Subject}
Due: {time + 86400}
diff --git a/t/approval/basic.t b/t/approval/basic.t
index 2d00eb5..31b869c 100644
--- a/t/approval/basic.t
+++ b/t/approval/basic.t
@@ -33,7 +33,6 @@ my $approvals =
Queue: ___Approvals
Type: approval
Owner: CFO
-Requestors: {$Tickets{"TOP"}->Requestors}
Refers-To: TOP
Subject: CFO Approval for PO: {$Tickets{"TOP"}->Id} - {$Tickets{"TOP"}->Subject}
Due: {time + 86400}
@@ -46,7 +45,6 @@ ENDOFCONTENT
Queue: ___Approvals
Type: approval
Owner: CEO
-Requestors: {$Tickets{"TOP"}->Requestors}
Subject: PO approval request for {$Tickets{"TOP"}->Subject}
Refers-To: TOP
Depends-On: for-CFO
commit 52c44bb6d4d7e65f45026bec9a837be3419823f7
Author: Thomas Sibley <trs at bestpractical.com>
Date: Wed May 8 15:41:06 2013 -0700
Tests: Catch warnings when calling DecodeMIMEWordsTo* without a field name
Or provide a field name when possible to avoid the warnings altogether.
We explicitly test without field names to compare results, but no where
in core RT should do the same.
diff --git a/t/mail/mime_decoding.t b/t/mail/mime_decoding.t
index afb2032..b6d371c 100644
--- a/t/mail/mime_decoding.t
+++ b/t/mail/mime_decoding.t
@@ -2,17 +2,20 @@ use strict;
use warnings;
use RT::Test nodb => 1, tests => undef;
use Test::LongString;
+use Test::Warn;
use_ok('RT::I18N');
diag q{'=' char in a leading part before an encoded part};
{
my $str = 'key="plain"; key="=?UTF-8?B?0LzQvtC5X9GE0LDQudC7LmJpbg==?="';
- is(
- RT::I18N::DecodeMIMEWordsToUTF8($str),
- 'key="plain"; key="мой_Ñайл.bin"',
- "right decoding"
- );
+ warnings_like {
+ is(
+ RT::I18N::DecodeMIMEWordsToUTF8($str),
+ 'key="plain"; key="мой_Ñайл.bin"',
+ "right decoding"
+ );
+ } [qr/DecodeMIMEWordsTo.*?called without field name/i];
is(
RT::I18N::DecodeMIMEWordsToUTF8($str, 'content-disposition'),
'key="plain"; key="мой_Ñайл.bin"',
@@ -23,11 +26,13 @@ diag q{'=' char in a leading part before an encoded part};
diag q{not compliant with standards, but MUAs send such field when attachment has non-ascii in name};
{
my $str = 'attachment; filename="=?UTF-8?B?0LzQvtC5X9GE0LDQudC7LmJpbg==?="';
- is(
- RT::I18N::DecodeMIMEWordsToUTF8($str),
- 'attachment; filename="мой_Ñайл.bin"',
- "right decoding"
- );
+ warnings_like {
+ is(
+ RT::I18N::DecodeMIMEWordsToUTF8($str),
+ 'attachment; filename="мой_Ñайл.bin"',
+ "right decoding"
+ );
+ } [qr/DecodeMIMEWordsTo.*?called without field name/i];
is(
RT::I18N::DecodeMIMEWordsToUTF8($str, 'content-disposition'),
'attachment; filename="мой_Ñайл.bin"',
@@ -38,11 +43,13 @@ diag q{not compliant with standards, but MUAs send such field when attachment ha
diag q{'=' char in a trailing part after an encoded part};
{
my $str = 'attachment; filename="=?UTF-8?B?0LzQvtC5X9GE0LDQudC7LmJpbg==?="; some_prop="value"';
- is(
- RT::I18N::DecodeMIMEWordsToUTF8($str),
- 'attachment; filename="мой_Ñайл.bin"; some_prop="value"',
- "right decoding"
- );
+ warnings_like {
+ is(
+ RT::I18N::DecodeMIMEWordsToUTF8($str),
+ 'attachment; filename="мой_Ñайл.bin"; some_prop="value"',
+ "right decoding"
+ );
+ } [qr/DecodeMIMEWordsTo.*?called without field name/i];
is(
RT::I18N::DecodeMIMEWordsToUTF8($str, 'content-disposition'),
'attachment; filename="мой_Ñайл.bin"; some_prop="value"',
@@ -64,11 +71,13 @@ diag q{regression test for #5248 from rt3.fsck.com};
diag q{newline and encoded file name};
{
my $str = qq{application/vnd.ms-powerpoint;\n\tname="=?ISO-8859-1?Q?Main_presentation.ppt?="};
- is(
- RT::I18N::DecodeMIMEWordsToUTF8($str),
- qq{application/vnd.ms-powerpoint;\tname="Main presentation.ppt"},
- "right decoding"
- );
+ warnings_like {
+ is(
+ RT::I18N::DecodeMIMEWordsToUTF8($str),
+ qq{application/vnd.ms-powerpoint;\tname="Main presentation.ppt"},
+ "right decoding"
+ );
+ } [qr/DecodeMIMEWordsTo.*?called without field name/i];
is(
RT::I18N::DecodeMIMEWordsToUTF8($str,'content-type'),
qq{application/vnd.ms-powerpoint; name="Main presentation.ppt"},
@@ -111,7 +120,7 @@ diag q{canonicalize mime word encodings like gb2312};
=?gb2312?B?dHRhY2hlbWVudCB0ZXN0IGluIENOIHNpbXBsaWZpZWQ=?=};
is(
- RT::I18N::DecodeMIMEWordsToUTF8($str),
+ RT::I18N::DecodeMIMEWordsToUTF8($str, "Subject"),
qq{Subject: å¨ä¸çåå°å
±æè¶
é_Simplified_CN_GB2312attachement test in CN simplified},
"right decoding"
);
@@ -119,44 +128,47 @@ diag q{canonicalize mime word encodings like gb2312};
diag q{Whitespace between encoded words should be removed};
{
- my $str = "=?utf-8?Q?=E3=82=AD?= =?utf-8?Q?=E3=83=A3?=";
- is(
- RT::I18N::DecodeMIMEWordsToUTF8($str),
- "ãã£",
- "whitespace between encoded words is removed",
- );
-
- $str = "=?utf-8?Q?=E3=82=AD?= \n =?utf-8?Q?=E3=83=A3?=";
- is(
- RT::I18N::DecodeMIMEWordsToUTF8($str),
- "ãã£",
- "newlines between encoded words also removed",
- );
+ warnings_like {
+ my $str = "=?utf-8?Q?=E3=82=AD?= =?utf-8?Q?=E3=83=A3?=";
+ is(
+ RT::I18N::DecodeMIMEWordsToUTF8($str),
+ "ãã£",
+ "whitespace between encoded words is removed",
+ );
+
+ $str = "=?utf-8?Q?=E3=82=AD?= \n =?utf-8?Q?=E3=83=A3?=";
+ is(
+ RT::I18N::DecodeMIMEWordsToUTF8($str),
+ "ãã£",
+ "newlines between encoded words also removed",
+ );
+ } [(qr/DecodeMIMEWordsTo.*?called without field name/i) x 2];
}
diag q{Multiple octets split across QP hunks are correctly reassembled};
{
- # This passes even without explicit code to handle it because utf8
- # is perl's internal string encoding.
- my $str = "=?utf-8?Q?=E3?= =?utf-8?Q?=82?= =?utf-8?Q?=AD?=";
- is(
- RT::I18N::DecodeMIMEWordsToUTF8($str),
- "ã",
- "UTF8 character split in three is successfully reassembled",
- );
-
- # Non-utf8 encodings thus also must be checked
- $str = <<EOT; chomp $str;
+ warnings_like {
+ # This passes even without explicit code to handle it because utf8
+ # is perl's internal string encoding.
+ my $str = "=?utf-8?Q?=E3?= =?utf-8?Q?=82?= =?utf-8?Q?=AD?=";
+ is(
+ RT::I18N::DecodeMIMEWordsToUTF8($str),
+ "ã",
+ "UTF8 character split in three is successfully reassembled",
+ );
+
+ # Non-utf8 encodings thus also must be checked
+ $str = <<EOT; chomp $str;
=?gb2312?q?Chinese(gb2312)=20=20=C3=C0=B9=FA=C7=B0=CB=BE=B7=A8=B2=BF=B3?=
=?gb2312?q?=A4=C3=E6=BC=FB=C8=F8=B4=EF=C4=B7=BA=F3=B3=C6=C6=E4=D7=B4=CC=AC?=
=?gb2312?q?=BA=DC=BA=C3=20=20Chinese=20(gb2312)?=
EOT
- is(
- RT::I18N::DecodeMIMEWordsToUTF8($str),
- "Chinese(gb2312) ç¾å½åå¸æ³é¨é¿é¢è§è¨è¾¾å§å称å
¶ç¶æå¾å¥½ Chinese (gb2312)",
- "gb2312 character is successfully reassembled",
- );
-
+ is(
+ RT::I18N::DecodeMIMEWordsToUTF8($str),
+ "Chinese(gb2312) ç¾å½åå¸æ³é¨é¿é¢è§è¨è¾¾å§å称å
¶ç¶æå¾å¥½ Chinese (gb2312)",
+ "gb2312 character is successfully reassembled",
+ );
+ } [(qr/DecodeMIMEWordsTo.*?called without field name/i) x 2];
}
diag "multiple mime words containing special chars already in quotes";
commit d5a3d74fdb50089ea44101afe74665109b086411
Author: Thomas Sibley <trs at bestpractical.com>
Date: Wed May 8 15:43:42 2013 -0700
Tests: Set a correspond address
... so we don't try to parse an empty address on the way back in.
diff --git a/t/mail/multipart.t b/t/mail/multipart.t
index 1c11064..67f39d9 100644
--- a/t/mail/multipart.t
+++ b/t/mail/multipart.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use RT::Test tests => 4;
+use RT::Test tests => 4, config => q{Set($CorrespondAddress, 'rt at example.com');};
use RT::Test::Email;
my $queue = RT::Test->load_or_create_queue( Name => 'General' );
commit f428fe5e8f3dad991aca31a7e7c7ec25f9bc6049
Author: Thomas Sibley <trs at bestpractical.com>
Date: Wed May 8 15:44:22 2013 -0700
Tests: Double quotes are not allowed by our email address parsing
The double quote case for requestor email addresses is skipped further
down in the file, but the ticket was still created with a bogus
requestor. Avoid the added warnings by skipping the requestor when
testing double quotes.
diff --git a/t/web/googleish_search.t b/t/web/googleish_search.t
index a5f834e..73de128 100644
--- a/t/web/googleish_search.t
+++ b/t/web/googleish_search.t
@@ -164,7 +164,9 @@ for my $quote ( q{'}, q{"} ) {
Subject => qq!base${quote}ticket $$!,
Queue => 'general',
Owner => $user->Name,
- Requestor => qq!custom${quote}search\@localhost!,
+ ( $quote eq q{'}
+ ? (Requestor => qq!custom${quote}search\@localhost!)
+ : () ),
Content => qq!this is base${quote}ticket with quote inside!,
);
ok( $ticket_quote->id, 'created ticket with quote for custom search' );
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list