[Rt-commit] r8580 - in rt/branches/3.7-EXPERIMENTAL-TUNIS: lib/RT
lib/RT/Interface/Email/Auth
sartak at bestpractical.com
sartak at bestpractical.com
Thu Aug 16 13:37:51 EDT 2007
Author: sartak
Date: Thu Aug 16 13:37:50 2007
New Revision: 8580
Modified:
rt/branches/3.7-EXPERIMENTAL-TUNIS/ (props changed)
rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/EmailParser.pm
rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Interface/Email/Auth/GnuPG.pm
Log:
r30359 at caladan: sartak | 2007-08-16 13:36:37 -0400
Add 'exact' argument to RT::EmailParser to trigger MIME::Parser->decode_bodies(0)
Use it in RT::Interface::Email::Auth::GnuPG
We're almost there, RT::Crypt::GnuPG is emitting correctly-formatted data, must be some little issue remaining that's causing things to fail. One hopes :)
Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/EmailParser.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/EmailParser.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/EmailParser.pm Thu Aug 16 13:37:50 2007
@@ -91,7 +91,7 @@
# {{{ sub SmartParseMIMEEntityFromScalar
-=head2 SmartParseMIMEEntityFromScalar { Message => SCALAR_REF, Decode => BOOL }
+=head2 SmartParseMIMEEntityFromScalar { Message => SCALAR_REF, Decode => BOOL, [Exact => BOOL] }
Parse a message stored in a scalar from scalar_ref
@@ -99,7 +99,7 @@
sub SmartParseMIMEEntityFromScalar {
my $self = shift;
- my %args = ( Message => undef, Decode => 1, @_ );
+ my %args = ( Message => undef, Decode => 1, Exact => 0, @_ );
my ( $fh, $temp_file );
eval {
@@ -125,7 +125,7 @@
# We have to trust the temp file's name -- untaint it
$temp_file =~ /(.*)/;
- $self->ParseMIMEEntityFromFile( $1, $args{'Decode'} );
+ $self->ParseMIMEEntityFromFile( $1, $args{'Decode'}, $args{'Exact'} );
unlink($1);
}
}
@@ -134,7 +134,7 @@
#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'} );
+ $self->ParseMIMEEntityFromScalar( $args{'Message'}, $args{'Decode'}, $args{'Exact'} );
}
}
@@ -152,7 +152,8 @@
sub ParseMIMEEntityFromSTDIN {
my $self = shift;
my $postprocess = (@_ ? shift : 1);
- return $self->ParseMIMEEntityFromFileHandle(\*STDIN, $postprocess);
+ my $exact = shift;
+ return $self->ParseMIMEEntityFromFileHandle(\*STDIN, $postprocess, $exact);
}
# }}}
@@ -173,7 +174,8 @@
my $self = shift;
my $message = shift;
my $postprocess = (@_ ? shift : 1);
- $self->_ParseMIMEEntity($message,'parse_data', $postprocess);
+ my $exact = shift;
+ $self->_ParseMIMEEntity($message,'parse_data',$postprocess,$exact);
}
# }}}
@@ -190,7 +192,8 @@
my $self = shift;
my $filehandle = shift;
my $postprocess = (@_ ? shift : 1);
- $self->_ParseMIMEEntity($filehandle,'parse', $postprocess);
+ my $exact = shift;
+ $self->_ParseMIMEEntity($filehandle,'parse', $postprocess, $exact);
}
# }}}
@@ -207,7 +210,8 @@
my $self = shift;
my $file = shift;
my $postprocess = (@_ ? shift : 1);
- $self->_ParseMIMEEntity($file,'parse_open',$postprocess);
+ my $exact = shift;
+ $self->_ParseMIMEEntity($file,'parse_open',$postprocess,$exact);
}
# }}}
@@ -218,10 +222,12 @@
my $message = shift;
my $method = shift;
my $postprocess = shift;
+ my $exact = shift;
# Create a new parser object:
my $parser = MIME::Parser->new();
$self->_SetupMIMEParser($parser);
+ $parser->decode_bodies(0) if $exact;
# TODO: XXX 3.0 we really need to wrap this in an eval { }
Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Interface/Email/Auth/GnuPG.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Interface/Email/Auth/GnuPG.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Interface/Email/Auth/GnuPG.pm Thu Aug 16 13:37:50 2007
@@ -65,10 +65,12 @@
sub ApplyBeforeDecode { return 1 }
use RT::Crypt::GnuPG;
+use RT::EmailParser ();
sub GetCurrentUser {
my %args = (
Message => undef,
+ RawMessageRef => undef,
@_
);
@@ -76,7 +78,19 @@
for qw(X-RT-GnuPG-Status X-RT-Incoming-Encrypton
X-RT-Incoming-Signature X-RT-Privacy);
- my $msg = $args{'Message'}->dup;
+ my $decoded = $args{'Message'};
+
+ # GPG needs an exact copy of the message to properly verify signatures
+ # whitespace changes introduced by decoding and re-encoding means we're
+ # rejecting some properly signed emails, specifically on binary attachments
+ my $parser = RT::EmailParser->new();
+ $parser->SmartParseMIMEEntityFromScalar(
+ Message => ${$args{'RawMessageRef'}},
+ Decode => 0,
+ Exact => 1,
+ );
+ $args{'Message'} = $parser->Entity();
+
my ($status, @res) = VerifyDecrypt( Entity => $args{'Message'} );
if ( $status && !@res ) {
$args{'Message'}->head->add(
@@ -100,7 +114,7 @@
$args{'Message'}->attach(
Type => 'application/x-rt-original-message',
Disposition => 'inline',
- Data => $msg->as_string,
+ Data => $decoded->as_string,
);
$args{'Message'}->head->add( 'X-RT-GnuPG-Status' => $_->{'status'} )
More information about the Rt-commit
mailing list