[Rt-commit] [svn] r1063 - in rt/branches/rt-3.1: . lib/RT
jesse at pallas.eruditorum.org
jesse at pallas.eruditorum.org
Mon Jun 14 00:36:23 EDT 2004
Author: jesse
Date: Mon Jun 14 00:36:22 2004
New Revision: 1063
Modified:
rt/branches/rt-3.1/ (props changed)
rt/branches/rt-3.1/lib/RT/EmailParser.pm
Log:
----------------------------------------------------------------------
r1794 at debian: jesse | 2004-06-14T13:40:18.744831Z
Another attempt at fixing the taint bug
----------------------------------------------------------------------
Modified: rt/branches/rt-3.1/lib/RT/EmailParser.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/EmailParser.pm (original)
+++ rt/branches/rt-3.1/lib/RT/EmailParser.pm Mon Jun 14 00:36:22 2004
@@ -160,40 +160,45 @@
=cut
sub SmartParseMIMEEntityFromScalar {
- my $self = shift;
- my %args = ( Message => undef, Decode => 1, @_ );
-
+ my $self = shift;
+ my %args = ( Message => undef, Decode => 1, @_ );
my ( $fh, $temp_file );
- for ( 1 .. 10 ) {
+ eval {
- # on NFS and NTFS, it is possible that tempfile() conflicts
- # with other processes, causing a race condition. we try to
- # accommodate this by pausing and retrying.
- last
- if ( $fh, $temp_file ) =
- eval { File::Temp::tempfile( undef, UNLINK => 0 ) };
- sleep 1;
- }
- if ($fh) {
- binmode $fh;
+ for ( 1 .. 10 ) {
+
+ # on NFS and NTFS, it is possible that tempfile() conflicts
+ # with other processes, causing a race condition. we try to
+ # accommodate this by pausing and retrying.
+ last
+ if ( $fh, $temp_file ) =
+ eval { File::Temp::tempfile( undef, UNLINK => 0 ) };
+ sleep 1;
+ }
+ if ($fh) {
- #thank you, windows
- $fh->autoflush(1);
- print $fh $args{'Message'};
- close($fh);
- if ( -f $temp_file ) {
- # We have to trust the temp file's name -- untaint it
- $temp_file =~ /(.*)/;
- $self->ParseMIMEEntityFromFile($1, $args{'Decode'});
- unlink($1);
+ #thank you, windows
+ binmode $fh;
+ $fh->autoflush(1);
+ print $fh $args{'Message'};
+ close($fh);
+ if ( -f $temp_file ) {
+
+ # We have to trust the temp file's name -- untaint it
+ $temp_file =~ /(.*)/;
+ $self->ParseMIMEEntityFromFile( $1, $args{'Decode'} );
+ unlink($1);
+ }
}
- } #If for some reason we weren't able to parse the message using a temp file # try it with a scalar
- if ( !$self->Entity ) {
+ };
+
+ #If for some reason we weren't able to parse the message using a temp file
+ # try it with a scalar
+ if ( $@ || !$self->Entity ) {
$self->ParseMIMEEntityFromScalar( $args{'Message'}, $args{'Decode'} );
}
-
}
# {{{ sub ParseMIMEEntityFromSTDIN
More information about the Rt-commit
mailing list