[Rt-commit] rt branch, 4.0/unicode-recommended-filename, created. rt-4.0.0rc6-139-gf83bd25
Alex Vandiver
alexmv at bestpractical.com
Mon Aug 29 15:13:42 EDT 2011
The branch, 4.0/unicode-recommended-filename has been created
at f83bd2567d8452d4ec4a40aea4e606c0005ead3a (commit)
- Log -----------------------------------------------------------------
commit 0c2bcbdc0d1e16d745782c84d6adc8317b56597a
Author: sunnavy <sunnavy at bestpractical.com>
Date: Mon Mar 21 16:12:03 2011 +0800
test download link text
diff --git a/t/web/attachment_encoding.t b/t/web/attachment_encoding.t
index 2fe8200..5506bbd 100644
--- a/t/web/attachment_encoding.t
+++ b/t/web/attachment_encoding.t
@@ -82,7 +82,7 @@ diag 'test with attachemnts' if $ENV{TEST_VERBOSE};
$m->back;
$m->back;
- $m->follow_link_ok( { text_regex => qr/by Enoch Root/ },
+ $m->follow_link_ok( { text => 'Download é件.txt' },
'-> /Ticket/Attachment/...' );
$m->content_contains( 'é件', 'has content é件' );
commit f83bd2567d8452d4ec4a40aea4e606c0005ead3a
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed May 11 18:19:34 2011 +0800
Reimplement MIME::Head->recommended_filename for non-mime-encoded fields
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