[otrs-cvs] otrs/Kernel/System EmailParser.pm,1.110,1.111
"CVS commits notifications of OTRS.org" <[email protected]>
| Newsgroups | gmane.comp.otrs.cvs |
|---|---|
| Message-ID | <[email protected]> |
Comments:
Update of /home/cvs/otrs/Kernel/System
In directory lancelot:/tmp/cvs-serv2198/Kernel/System
Modified Files:
EmailParser.pm
Log Message:
- 2012-11-29 Fixed bug#1970 - Email attachments of type .msg (Outlook-Message) are converted.
Author: mg
Index: EmailParser.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/System/EmailParser.pm,v
retrieving revision 1.110
retrieving revision 1.111
diff -2 -u -d -r1.110 -r1.111
--- EmailParser.pm 20 Nov 2012 15:34:32 -0000 1.110
+++ EmailParser.pm 29 Nov 2012 12:39:49 -0000 1.111
@@ -153,4 +153,7 @@
my $Parser = MIME::Parser->new();
$Parser->output_to_core('ALL');
+
+ # Keep nested messages as attachments (see bug#1970).
+ $Parser->extract_nested_messages(0);
$Self->{ParserParts} = $Parser->parse_data( $Self->{Email}->as_string() );
}
@@ -718,10 +721,6 @@
}
- # check if there is no recommended_filename -> add file-NoFilenamePartCounter
- if ( !$Part->head()->recommended_filename() ) {
- $Self->{NoFilenamePartCounter}++;
- $PartData{Filename} = "file-$Self->{NoFilenamePartCounter}";
- }
- else {
+ # check if there is no recommended_filename or subject -> add file-NoFilenamePartCounter
+ if ( $Part->head()->recommended_filename() ) {
$PartData{Filename} = decode_mimewords( $Part->head()->recommended_filename() );
$PartData{ContentDisposition} = $Part->head()->get('Content-Disposition');
@@ -756,4 +755,35 @@
}
+ # Guess the filename for nested messages (see bug#1970).
+ elsif ( $PartData{ContentType} eq 'message/rfc822' ) {
+ my ($SubjectString) = $Part->as_string =~ m/^Subject: ([^\n]*(\n[ \t][^\n]*)*)/m;
+ my $Subject;
+ foreach my $Decoded ( decode_mimewords($SubjectString) ) {
+ if ( $Decoded->[0] ) {
+ $Subject .= $Self->{EncodeObject}->Convert2CharsetInternal(
+ Text => $Decoded->[0],
+ From => $Decoded->[1] || 'us-ascii',
+ Check => 1,
+ );
+ }
+ }
+
+ # trim whitespace
+ $Subject =~ s/^\s+|\n|\s+$//;
+ if ( length($Subject) > 246 ) {
+ $Subject = substr( $Subject, 0, 246 );
+ }
+
+ if ( $Subject eq '' ) {
+ $Self->{NoFilenamePartCounter}++;
+ $Subject = "Unbenannt-$Self->{NoFilenamePartCounter}";
+ }
+ $PartData{Filename} = $Subject . '.eml';
+ }
+ else {
+ $Self->{NoFilenamePartCounter}++;
+ $PartData{Filename} = "file-$Self->{NoFilenamePartCounter}";
+ }
+
# parse/get Content-Id and Content-Location for html email attachments
$PartData{ContentID} = $Part->head()->get('Content-Id');
---------------------------------------------------------------------
OTRS mailing list: cvs-log - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/cvs-log
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/cvs-log