[Bps-public-commit] RT-Extension-CommandByMail branch, master, updated. 2.01-8-gd6c1e9c

Alex Vandiver alexmv at bestpractical.com
Thu Jul 14 05:33:52 EDT 2016


The branch, master has been updated
       via  d6c1e9c73e9ec02458921c1e2094b763e8b110f9 (commit)
       via  8f842e609f875d6b052415c9a3b165b956ce14e7 (commit)
       via  2f7004506bfd1b182b4fbfe4331b32af579ddaf7 (commit)
       via  c1f5331199a01a58cc15a5c51bdf379200cd4e95 (commit)
      from  eb499050fc7af94b4e15bb5db3a5337947b20692 (commit)

Summary of changes:
 lib/RT/Extension/CommandByMail.pm         |  4 +++-
 lib/RT/Extension/CommandByMail/Test.pm.in | 13 ++-----------
 xt/create.t                               |  5 ++---
 3 files changed, 7 insertions(+), 15 deletions(-)

- Log -----------------------------------------------------------------
commit c1f5331199a01a58cc15a5c51bdf379200cd4e95
Author: Alex Vandiver <alex at chmrr.net>
Date:   Thu Jul 14 01:18:19 2016 -0700

    Switch to RT::Handle::cmp_version, which understands `rc`s, etc

diff --git a/lib/RT/Extension/CommandByMail/Test.pm.in b/lib/RT/Extension/CommandByMail/Test.pm.in
index 12b2812..7dcb764 100644
--- a/lib/RT/Extension/CommandByMail/Test.pm.in
+++ b/lib/RT/Extension/CommandByMail/Test.pm.in
@@ -30,7 +30,8 @@ sub bootstrap_more_config{
     my $config = shift;
     my $args_ref = shift;
 
-    if ( RT_at_or_newer_than('4.4.0') ){
+    require RT::Handle;
+    if ( RT::Handle::cmp_version($RT::VERSION,'4.4.0') >= 0 ){
         print $config "Set( \@MailPlugins, qw(Auth::MailFrom Action::CommandByMail));\n";
     }
     else{
@@ -39,14 +40,4 @@ sub bootstrap_more_config{
     return;
 }
 
-sub RT_at_or_newer_than{
-    my $version = shift;
-    my ($my_major, $my_minor, $my_sub) = split(/\./, $version);
-    my ($major, $minor, $sub) = split(/\./, $RT::VERSION);
-    return ($my_major >= $major
-            and $my_minor >= $minor
-            and $my_sub >= $sub)
-            ? 1 : 0;
-}
-
 1;

commit 2f7004506bfd1b182b4fbfe4331b32af579ddaf7
Author: Alex Vandiver <alex at chmrr.net>
Date:   Thu Jul 14 01:18:53 2016 -0700

    Pass encoded headers as they will be ingested, MIME-encoded
    
    The "Subject" header, if it contains UTF-8 characters, will be passed
    in MIME-encoded.  Switch the test to injecting the email with the
    header so encoded.
    
    The test fails under Postgres, showing signs of double-encoding.  It
    passes on MySQL and SQLite, due to more lax character/byte semantics.

diff --git a/xt/create.t b/xt/create.t
index e8c946b..c4c891f 100644
--- a/xt/create.t
+++ b/xt/create.t
@@ -26,7 +26,7 @@ END
 diag("test with umlaut in subject") if $ENV{'TEST_VERBOSE'};
 {
     my $text = <<END;
-Subject: test Brontë
+Subject: test =?UTF-8?B?QnJvbnTDqw==?=
 From: root\@localhost
 
 test

commit 8f842e609f875d6b052415c9a3b165b956ce14e7
Author: Alex Vandiver <alex at chmrr.net>
Date:   Thu Jul 14 02:20:54 2016 -0700

    Switch from "use utf8" to explicit decode(), for clarity
    
    Use of "use utf8" requires that the programmer constantly be aware
    that string literals may be treated with character semantics, instead
    of byte semantics, depending on lexical scope.  Make clear that the
    return of ->Subject contains characters, not bytes, by leaving them as
    bytes in the literal, and explicitly decoding them.
    
    See 7548587b in RT.

diff --git a/xt/create.t b/xt/create.t
index c4c891f..d1fb5f5 100644
--- a/xt/create.t
+++ b/xt/create.t
@@ -1,6 +1,5 @@
 use strict;
 use warnings;
-use utf8;
 
 use RT::Extension::CommandByMail::Test tests => undef;
 my $test = 'RT::Extension::CommandByMail::Test';
@@ -36,7 +35,7 @@ END
     my $obj = RT::Ticket->new( $RT::SystemUser );
     $obj->Load( $id );
     is($obj->id, $id, "loaded ticket");
-    is($obj->Subject, "test Brontë", "got correct subject with umlauts");
+    is($obj->Subject, Encode::decode("UTF-8","test Brontë"), "got correct subject with umlauts");
 }
 
 # XXX: use statuses from config/libs

commit d6c1e9c73e9ec02458921c1e2094b763e8b110f9
Author: Alex Vandiver <alex at chmrr.net>
Date:   Thu Jul 14 02:26:33 2016 -0700

    Explicitly decode all values extracted from MIME headers
    
    RT normalizes all headers to be in UTF-8, and requires that all
    consumes explicitly decode them into characters if they wish to treat
    them as characters; see 41d084f1 in RT.
    
    In both locations which directly access `->head->get()` or equivalent,
    decode the header value.

diff --git a/lib/RT/Extension/CommandByMail.pm b/lib/RT/Extension/CommandByMail.pm
index c5e4cd5..d82992f 100644
--- a/lib/RT/Extension/CommandByMail.pm
+++ b/lib/RT/Extension/CommandByMail.pm
@@ -345,7 +345,8 @@ sub ProcessCommands {
     }
 
     if (defined $headername) {
-        unshift @content, $args{'Message'}->head->get_all($headername);
+        unshift @content, map {Encode::decode("UTF-8",$_)}
+            $args{'Message'}->head->get_all($headername);
     }
 
     my @items;
@@ -683,6 +684,7 @@ sub ProcessCommands {
         # subject
         unless ( $create_args{'Subject'} ) {
             $create_args{'Subject'} = $args{'Message'}->head->get('Subject');
+            $create_args{'Subject'} = Encode::decode("UTF-8", $create_args{'Subject'});
             chomp $create_args{'Subject'};
         }
 

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list