[Rt-commit] r17109 - in rt/3.8/trunk: share/html/SelfService share/html/Ticket
ruz at bestpractical.com
ruz at bestpractical.com
Thu Dec 4 23:52:46 EST 2008
Author: ruz
Date: Thu Dec 4 23:52:45 2008
New Revision: 17109
Modified:
rt/3.8/trunk/lib/RT/Interface/Web.pm
rt/3.8/trunk/share/html/SelfService/Display.html
rt/3.8/trunk/share/html/Ticket/Create.html
rt/3.8/trunk/share/html/Ticket/ModifyAll.html
rt/3.8/trunk/share/html/Ticket/Update.html
Log:
* minimize code around preparing file attachments, move code into MakeMIMEEntity
to avoid loosing UTF-8 flag on file names in subject
Modified: rt/3.8/trunk/lib/RT/Interface/Web.pm
==============================================================================
--- rt/3.8/trunk/lib/RT/Interface/Web.pm (original)
+++ rt/3.8/trunk/lib/RT/Interface/Web.pm Thu Dec 4 23:52:45 2008
@@ -779,16 +779,17 @@
# Prefer the cached name first over CGI.pm stringification.
my $filename = $RT::Mason::CGI::Filename;
$filename = "$filehandle" unless defined($filename);
-
- $filename =~ s#^.*[\\/]##;
+ $filename = Encode::decode_utf8($filename);
+ $filename =~ s{^.*[\\/]}{};
-
-
$Message->attach(
Type => $uploadinfo->{'Content-Type'},
- Filename => Encode::decode_utf8($filename),
+ Filename => $filename,
Data => \@content,
);
+ if ( !$args{'Subject'} && !(defined $args{'Body'} && length $args{'Body'}) ) {
+ $Message->head->set( 'Subject' => $filename );
+ }
}
}
Modified: rt/3.8/trunk/share/html/SelfService/Display.html
==============================================================================
--- rt/3.8/trunk/share/html/SelfService/Display.html (original)
+++ rt/3.8/trunk/share/html/SelfService/Display.html Thu Dec 4 23:52:45 2008
@@ -101,23 +101,15 @@
if ( $ARGS{'Attach'} ) { # attachment?
$session{'Attachments'} = {} unless defined $session{'Attachments'};
- my $subject = "$ARGS{'Attach'}";
-
- # since CGI.pm deutf8izes the magic field, we need to add it back.
- Encode::_utf8_on($subject);
-
- # strip leading directories
- $subject =~ s#^.*[\\/]##;
-
my $attachment = MakeMIMEEntity(
- Subject => $subject,
- Body => "",
AttachmentFieldName => 'Attach'
);
- $session{'Attachments'} =
- { %{ $session{'Attachments'} || {} },
- $ARGS{'Attach'} => $attachment };
+ my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
+ $session{'Attachments'} = {
+ %{ $session{'Attachments'} || {} },
+ $file_path => $attachment,
+ };
}
if ( defined ($id[0]) && $id[0] eq 'new' ) {
Modified: rt/3.8/trunk/share/html/Ticket/Create.html
==============================================================================
--- rt/3.8/trunk/share/html/Ticket/Create.html (original)
+++ rt/3.8/trunk/share/html/Ticket/Create.html Thu Dec 4 23:52:45 2008
@@ -350,17 +350,11 @@
# {{{ store the uploaded attachment in session
if ($ARGS{'Attach'}) { # attachment?
- $session{'Attachments'} = {} unless defined $session{'Attachments'};
-
- my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
- my ($file_name) = $file_path =~ m{([\\/]+)$};
-
my $attachment = MakeMIMEEntity(
- Subject => $file_name,
- Body => "",
AttachmentFieldName => 'Attach'
);
+ my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
$session{'Attachments'} = {
%{$session{'Attachments'} || {}},
$file_path => $attachment,
Modified: rt/3.8/trunk/share/html/Ticket/ModifyAll.html
==============================================================================
--- rt/3.8/trunk/share/html/Ticket/ModifyAll.html (original)
+++ rt/3.8/trunk/share/html/Ticket/ModifyAll.html Thu Dec 4 23:52:45 2008
@@ -176,19 +176,12 @@
push @results, ProcessTicketDates( TicketObj => $Ticket, ARGSRef => \%ARGS);
if ($ARGS{'UpdateAttachment'}) {
- my $subject = "$ARGS{'UpdateAttachment'}";
- # since CGI.pm deutf8izes the magic field, we need to add it back.
- Encode::_utf8_on($subject);
- # strip leading directories
- $subject =~ s#^.*[\\/]##;
-
my $attachment = MakeMIMEEntity(
- Subject => $subject,
- Body => "",
- AttachmentFieldName => 'UpdateAttachment'
+ AttachmentFieldName => 'UpdateAttachment'
);
+ my $file_path = Encode::decode_utf8("$ARGS{'UpdateAttachment'}");
+ $ARGS{'UpdateAttachments'}->{ $file_path } = $attachment;
delete $ARGS{'UpdateAttachment'};
- $ARGS{'UpdateAttachments'}->{ $subject } = $attachment;
}
push @results, ProcessUpdateMessage( TicketObj => $Ticket, ARGSRef=>\%ARGS );
Modified: rt/3.8/trunk/share/html/Ticket/Update.html
==============================================================================
--- rt/3.8/trunk/share/html/Ticket/Update.html (original)
+++ rt/3.8/trunk/share/html/Ticket/Update.html Thu Dec 4 23:52:45 2008
@@ -214,22 +214,15 @@
# {{{ store the uploaded attachment in session
if ($ARGS{'Attach'}) { # attachment?
- $session{'Attachments'} = {} unless defined $session{'Attachments'};
-
- my $subject = "$ARGS{'Attach'}";
- # since CGI.pm deutf8izes the magic field, we need to add it back.
- Encode::_utf8_on($subject);
- # strip leading directories
- $subject =~ s#^.*[\\/]##;
-
my $attachment = MakeMIMEEntity(
- Filename => $subject,
- Body => "",
AttachmentFieldName => 'Attach'
);
- $session{'Attachments'} = { %{$session{'Attachments'} || {}},
- $ARGS{'Attach'} => $attachment };
+ my $file_path = Encode::decode_utf8("$ARGS{'Attach'}");
+ $session{'Attachments'} = {
+ %{$session{'Attachments'} || {}},
+ $file_path => $attachment,
+ };
}
# }}}
More information about the Rt-commit
mailing list