[Rt-commit] r7119 - in rt/branches/3.7-EXPERIMENTAL: .
ruz at bestpractical.com
ruz at bestpractical.com
Fri Mar 2 14:35:27 EST 2007
Author: ruz
Date: Fri Mar 2 14:35:26 2007
New Revision: 7119
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm
Log:
r4640 at cubic-pc: cubic | 2007-03-02 05:24:34 +0300
* don't add empty $args{'Body'} to MIME as ->make_singlepart method doesn't
catch this case and we create useless empty attachments and too nested
entities. Now we do the right thing in all cases: text body, file upload,
body+upload or none of those at all.
Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Interface/Web.pm Fri Mar 2 14:35:26 2007
@@ -633,58 +633,60 @@
Cc => undef,
Body => undef,
AttachmentFieldName => undef,
-# map Encode::encode_utf8($_), @_,
@_,
);
+ my $Message = MIME::Entity->build(
+ Type => 'multipart/mixed',
+ Subject => $args{'Subject'} || "",
+ From => $args{'From'},
+ Cc => $args{'Cc'},
+ );
- #Make the update content have no 'weird' newlines in it
+ if ( defined $args{'Body'} && length $args{'Body'} ) {
+ # Make the update content have no 'weird' newlines in it
+ $args{'Body'} =~ s/\r\n/\n/gs;
- $args{'Body'} =~ s/\r\n/\n/gs;
- my $Message;
- {
# MIME::Head is not happy in utf-8 domain. This only happens
# when processing an incoming email (so far observed).
no utf8;
use bytes;
- $Message = MIME::Entity->build(
- Subject => $args{'Subject'} || "",
- From => $args{'From'},
- Cc => $args{'Cc'},
- Charset => 'utf8',
- Data => [ $args{'Body'} ]
+ $Message->attach(
+ Type => 'text/plain',
+ Charset => 'UTF-8',
+ Data => $args{'Body'},
);
}
- my $cgi_object = $m->cgi_object;
+ if ( $args{'AttachmentFieldName'} ) {
- if (my $filehandle = $cgi_object->upload( $args{'AttachmentFieldName'} ) ) {
+ my $cgi_object = $m->cgi_object;
- my (@content,$buffer);
- while ( my $bytesread = read( $filehandle, $buffer, 4096 ) ) {
- push @content, $buffer;
- }
+ if ( my $filehandle = $cgi_object->upload( $args{'AttachmentFieldName'} ) ) {
- my $uploadinfo = $cgi_object->uploadInfo($filehandle);
-
- # Prefer the cached name first over CGI.pm stringification.
- my $filename = $RT::Mason::CGI::Filename;
- $filename = "$filehandle" unless defined($filename);
-
- $filename =~ s#^.*[\\/]##;
+ my (@content,$buffer);
+ while ( my $bytesread = read( $filehandle, $buffer, 4096 ) ) {
+ push @content, $buffer;
+ }
+ my $uploadinfo = $cgi_object->uploadInfo($filehandle);
-
- $Message->attach(
- Data => \@content,
- Filename => Encode::decode_utf8($filename),
- Type => $uploadinfo->{'Content-Type'},
- );
+ # Prefer the cached name first over CGI.pm stringification.
+ my $filename = $RT::Mason::CGI::Filename;
+ $filename = "$filehandle" unless defined($filename);
+
+ $filename =~ s#^.*[\\/]##;
- # }
+
+ $Message->attach(
+ Type => $uploadinfo->{'Content-Type'},
+ Filename => Encode::decode_utf8($filename),
+ Data => \@content,
+ );
+ }
}
- $Message->make_singlepart();
+ $Message->make_singlepart;
RT::I18N::SetMIMEEntityToUTF8($Message); # convert text parts into utf-8
return ($Message);
More information about the Rt-commit
mailing list