[Rt-commit] r2798 - in rt/branches/3.0-MAINT: . lib/RT
lib/RT/Interface
jesse at bestpractical.com
jesse at bestpractical.com
Thu Apr 21 15:08:29 EDT 2005
Author: jesse
Date: Thu Apr 21 15:08:29 2005
New Revision: 2798
Modified:
rt/branches/3.0-MAINT/ (props changed)
rt/branches/3.0-MAINT/lib/RT/EmailParser.pm
rt/branches/3.0-MAINT/lib/RT/Interface/Email.pm
Log:
r14013 at hualien: jesse | 2005-04-21 15:07:19 -0400
* Additional bullet-proofing against possible out of space issues when creating tickets
Modified: rt/branches/3.0-MAINT/lib/RT/EmailParser.pm
==============================================================================
--- rt/branches/3.0-MAINT/lib/RT/EmailParser.pm (original)
+++ rt/branches/3.0-MAINT/lib/RT/EmailParser.pm Thu Apr 21 15:08:29 2005
@@ -175,7 +175,7 @@
my $self = shift;
my $message = shift;
- $self->_DoParse('parse_data', $message);
+ return $self->_DoParse('parse_data', $message);
}
@@ -191,7 +191,7 @@
my $self = shift;
my $filehandle = shift;
- $self->_DoParse('parse', $filehandle);
+ return $self->_DoParse('parse', $filehandle);
}
@@ -209,7 +209,7 @@
my $self = shift;
my $file = shift;
- $self->_DoParse('parse_open', $file);
+ return $self->_DoParse('parse_open', $file);
}
# }}}
@@ -224,28 +224,34 @@
=cut
sub _DoParse {
- my $self = shift;
+ my $self = shift;
my $method = shift;
- my $file = shift;
+ my $file = shift;
# Create a new parser object:
-
+ warn "herE";
my $parser = MIME::Parser->new();
$self->_SetupMIMEParser($parser);
-
-
- # TODO: XXX 3.0 we really need to wrap this in an eval { }
-
- unless ( $self->{'entity'} = $parser->$method($file) ) {
-
+ warn "here2";
+ eval { $self->{'entity'} = $parser->$method($file); };
+ warn "here3";
+ unless ( $self->{'entity'} ) {
+ warn "here4";
# Try again, this time without extracting nested messages
$parser->extract_nested_messages(0);
- unless ( $self->{'entity'} = $parser->$method($file) ) {
+ warn "here5";
+ eval { $self->{'entity'} = $parser->$method($file); };
+ warn "here6";
+ unless ( $self->{'entity'} ) {
+ warn "here7";
$RT::Logger->crit("couldn't parse MIME stream");
- return ( undef);
+ return (undef);
}
+ warn "her8";
}
+ warn "here9";
$self->_PostProcessNewEntity();
+ warn "ehre10";
return (1);
}
Modified: rt/branches/3.0-MAINT/lib/RT/Interface/Email.pm
==============================================================================
--- rt/branches/3.0-MAINT/lib/RT/Interface/Email.pm (original)
+++ rt/branches/3.0-MAINT/lib/RT/Interface/Email.pm Thu Apr 21 15:08:29 2005
@@ -415,6 +415,8 @@
}
my $parser = RT::EmailParser->new();
+ my $parse_status;
+ eval { # Traip failures to create a file
my ( $fh, $temp_file );
for ( 1 .. 10 ) {
@@ -427,27 +429,27 @@
if ($fh) {
binmode $fh; #thank you, windows
$fh->autoflush(1);
- print $fh $args{'message'};
+ print $fh $args{'message'} || die $@;
close($fh);
if ( -f $temp_file ) {
- $parser->ParseMIMEEntityFromFile($temp_file);
+ $parse_status = $parser->ParseMIMEEntityFromFile($temp_file);
unlink( $temp_file );
- if ($parser->Entity) {
+ if ($parse_status && $parser->Entity) {
delete $args{'message'};
}
}
}
-
+ };
#If for some reason we weren't able to parse the message using a temp file
# try it with a scalar
if ($args{'message'}) {
- $parser->ParseMIMEEntityFromScalar($args{'message'});
+ $parse_status = $parser->ParseMIMEEntityFromScalar($args{'message'});
}
- if (!$parser->Entity()) {
+ if (!$parse_status) {
MailError(
To => $RT::OwnerEmail,
Subject => "RT Bounce: Unparseable message",
@@ -455,7 +457,7 @@
Attach => $args{'message'}
);
- return(0,"Failed to parse this message. Something is likely badly wrong with the message");
+ return(-75,"Failed to parse this message. Something is likely badly wrong with the message or mail server");
}
my $Message = $parser->Entity();
More information about the Rt-commit
mailing list