[Rt-commit] rt branch, 4.0/att-filename-fix, updated. rt-4.0.0rc6-145-g260c431

? sunnavy sunnavy at bestpractical.com
Wed May 11 06:35:30 EDT 2011


The branch, 4.0/att-filename-fix has been updated
       via  260c4318abdc31fcc4bfd0a48c640b288963f761 (commit)
       via  3952b9be3502b66067f1e51edc713b51a1a2f636 (commit)
       via  efc81850e0df5222c26cec30c91417ecb5436ddf (commit)
      from  709155a5f490f0243d1aec5f66a26e82d1c68e4a (commit)

Summary of changes:
 lib/RT/Attachment.pm         |    5 ++++-
 lib/RT/Crypt/GnuPG.pm        |    4 ++--
 lib/RT/I18N.pm               |   10 +++-------
 lib/RT/Util.pm               |   23 ++++++++++++++++++++++-
 sbin/rt-test-dependencies.in |    2 +-
 5 files changed, 32 insertions(+), 12 deletions(-)

- Log -----------------------------------------------------------------
commit efc81850e0df5222c26cec30c91417ecb5436ddf
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed May 11 18:01:04 2011 +0800

    Revert "it's anti-rfc to not encode mime heads"
    
    to be consistent, all the other fields are utf8 string.
    
    This reverts commit 1f04962dda0991ccd5b746a9f98def588c8e9e83.

diff --git a/lib/RT/I18N.pm b/lib/RT/I18N.pm
index 88b772d..a1f2af5 100644
--- a/lib/RT/I18N.pm
+++ b/lib/RT/I18N.pm
@@ -226,13 +226,9 @@ sub SetMIMEEntityToEncoding {
 
     # 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) and !$preserve_words ) {
-            $head->mime_attr(
-                $attr => MIME::Words::encode_mimewords(
-                    DecodeMIMEWordsToUTF8($name), Charset => $enc,
-                )
-            );
-        }
+	if ( my $name = $head->mime_attr($attr) and !$preserve_words ) {
+	    $head->mime_attr( $attr => DecodeMIMEWordsToUTF8($name) );
+	}
     }
 
     # If this is a textual entity, we'd need to preserve its original encoding

commit 3952b9be3502b66067f1e51edc713b51a1a2f636
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed May 11 18:02:24 2011 +0800

    Revert "require 5.502+ of MIME::Entity as it has incompatible changes, see #16909"
    
    no need to require this high version as we don't need the new behavior now.
    
    This reverts commit 709155a5f490f0243d1aec5f66a26e82d1c68e4a.

diff --git a/sbin/rt-test-dependencies.in b/sbin/rt-test-dependencies.in
index 15ff1e0..2b34925 100755
--- a/sbin/rt-test-dependencies.in
+++ b/sbin/rt-test-dependencies.in
@@ -192,7 +192,7 @@ Sys::Syslog 0.16
 Locale::Maketext 1.06
 Locale::Maketext::Lexicon 0.32
 Locale::Maketext::Fuzzy
-MIME::Entity 5.502
+MIME::Entity 5.425
 Mail::Mailer 1.57
 Email::Address
 Text::Wrapper 

commit 260c4318abdc31fcc4bfd0a48c640b288963f761
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed May 11 18:19:34 2011 +0800

    MIME::Head->recommended_filename requires faileds be valid mime encoded, we can't meet that now, so mimic mime_recommended_filename instead

diff --git a/lib/RT/Attachment.pm b/lib/RT/Attachment.pm
index 7fc9aba..a5b0b91 100644
--- a/lib/RT/Attachment.pm
+++ b/lib/RT/Attachment.pm
@@ -78,6 +78,7 @@ use warnings;
 use RT::Transaction;
 use MIME::Base64;
 use MIME::QuotedPrint;
+use RT::Util 'mime_recommended_filename';
 
 sub _OverlayAccessible {
   {
@@ -138,7 +139,9 @@ sub Create {
     $MessageId =~ s/^<(.*?)>$/$1/o;
 
     #Get the filename
-    my $Filename = $Attachment->head->recommended_filename;
+
+    my $Filename = mime_recommended_filename($Attachment);
+
     # remove path part. 
     $Filename =~ s!.*/!! if $Filename;
 
diff --git a/lib/RT/Crypt/GnuPG.pm b/lib/RT/Crypt/GnuPG.pm
index 44d4286..63a605d 100644
--- a/lib/RT/Crypt/GnuPG.pm
+++ b/lib/RT/Crypt/GnuPG.pm
@@ -54,7 +54,7 @@ package RT::Crypt::GnuPG;
 use IO::Handle;
 use GnuPG::Interface;
 use RT::EmailParser ();
-use RT::Util 'safe_run_child';
+use RT::Util 'safe_run_child', 'mime_recommended_filename';
 
 =head1 NAME
 
@@ -769,7 +769,7 @@ sub _SignEncryptAttachmentInline {
         return %res;
     }
 
-    my $filename = $entity->head->recommended_filename || 'no_name';
+    my $filename = mime_recommended_filename( $entity ) || 'no_name';
     if ( $args{'Sign'} && !$args{'Encrypt'} ) {
         $entity->make_multipart;
         $entity->attach(
diff --git a/lib/RT/Util.pm b/lib/RT/Util.pm
index 82d07be..d2220c8 100644
--- a/lib/RT/Util.pm
+++ b/lib/RT/Util.pm
@@ -52,7 +52,7 @@ use warnings;
 
 
 use base 'Exporter';
-our @EXPORT = qw/safe_run_child/;
+our @EXPORT = qw/safe_run_child mime_recommended_filename/;
 
 sub safe_run_child (&) {
     my $our_pid = $$;
@@ -96,6 +96,27 @@ sub safe_run_child (&) {
     return $want? (@res) : $res[0];
 }
 
+=head2 mime_recommended_filename( MIME::Head|MIME::Entity )
+
+# mimic our own recommended_filename
+# since MIME-tools 5.501, head->recommended_filename requires the head are
+# mime encoded, we don't meet this yet.
+
+=cut
+
+sub mime_recommended_filename {
+    my $head = shift;
+    $head = $head->head if $head->isa('MIME::Entity');
+
+    for my $attr_name (qw( content-disposition.filename content-type.name )) {
+        my $value = $head->mime_attr($attr_name);
+        if ( defined $value && $value =~ /\S/ ) {
+            return $value;
+        }
+    }
+    return;
+}
+
 RT::Base->_ImportOverlays();
 
 1;

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


More information about the Rt-commit mailing list