[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.8-70-gac1049b

? sunnavy sunnavy at bestpractical.com
Thu Jun 3 02:51:50 EDT 2010


The branch, 3.8-trunk has been updated
       via  ac1049ba3b1ec64028a2f0557454a6a6e429231a (commit)
       via  1a068ee8521ed4e474728f79f2aeed17d5b26197 (commit)
      from  297ba4f9d7772aef6720841b89964f396d2ee09e (commit)

Summary of changes:
 lib/RT/Attachment_Overlay.pm |    2 ++
 t/api/attachment_filename.t  |   39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)
 create mode 100644 t/api/attachment_filename.t

- Log -----------------------------------------------------------------
commit 1a068ee8521ed4e474728f79f2aeed17d5b26197
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Jun 3 14:51:31 2010 +0800

    attachment's filename test

diff --git a/t/api/attachment_filename.t b/t/api/attachment_filename.t
new file mode 100644
index 0000000..2eced01
--- /dev/null
+++ b/t/api/attachment_filename.t
@@ -0,0 +1,39 @@
+use RT::Test tests => 5;
+use MIME::Entity;
+my $ticket = RT::Ticket->new($RT::SystemUser);
+my $mime   = MIME::Entity->build(
+    From => 'test at example.com',
+    Type => 'text/html',
+    Data => ["test attachment's filename\n"],
+);
+
+$mime->attach(
+    Path     => 'share/html/NoAuth/images/bplogo.gif',
+    Type     => 'image/gif',
+);
+
+$mime->attach(
+    Path     => 'share/html/NoAuth/images/bplogo.gif',
+    Type     => 'image/gif',
+    Filename => 'bplogo.gif',
+);
+
+$mime->attach(
+    Path     => 'share/html/NoAuth/images/bplogo.gif',
+    Filename => 'images/bplogo.gif',
+    Type     => 'image/gif',
+);
+
+my $id = $ticket->Create( MIMEObj => $mime, Queue => 'General' );
+ok( $id, "created ticket $id" );
+
+my $atts = RT::Attachments->new( $RT::SystemUser );
+$atts->Limit( FIELD => 'ContentType', VALUE => 'image/gif' );
+is( $atts->Count, 3, 'got 3 gif files' );
+
+# no matter if mime's filename include path or not,
+# we should throw away the path all the time.
+while ( my $att = $atts->Next ) {
+    is( $att->Filename, 'bplogo.gif', "attachment's filename" );
+}
+

commit ac1049ba3b1ec64028a2f0557454a6a6e429231a
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Jun 3 14:52:12 2010 +0800

    remove path part of filename of attachment

diff --git a/lib/RT/Attachment_Overlay.pm b/lib/RT/Attachment_Overlay.pm
index e2707a7..8406590 100644
--- a/lib/RT/Attachment_Overlay.pm
+++ b/lib/RT/Attachment_Overlay.pm
@@ -132,6 +132,8 @@ sub Create {
 
     #Get the filename
     my $Filename = $Attachment->head->recommended_filename;
+    # remove path part. 
+    $Filename =~ s!.*/!! if $Filename;
 
     # MIME::Head doesn't support perl strings well and can return
     # octets which later will be double encoded in low-level code

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


More information about the Rt-commit mailing list