diff options
author | Martin Blapp <mbr@FreeBSD.org> | 2004-09-02 22:28:22 +0000 |
---|---|---|
committer | Martin Blapp <mbr@FreeBSD.org> | 2004-09-02 22:28:22 +0000 |
commit | fc918f70f48c8784f1c159aaddadce224bca7308 (patch) | |
tree | c4b937c920a70c109784c5590d7d3b47a9417d5f /mail/p5-MIME-Tools | |
parent | 25e1eade83ce190c65023070eb9383fa36b2483a (diff) | |
download | ports-fc918f70f48c8784f1c159aaddadce224bca7308.tar.gz ports-fc918f70f48c8784f1c159aaddadce224bca7308.zip |
Notes
Diffstat (limited to 'mail/p5-MIME-Tools')
-rw-r--r-- | mail/p5-MIME-Tools/files/patch-Parser-MaxParts | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/mail/p5-MIME-Tools/files/patch-Parser-MaxParts b/mail/p5-MIME-Tools/files/patch-Parser-MaxParts new file mode 100644 index 000000000000..75f150286be0 --- /dev/null +++ b/mail/p5-MIME-Tools/files/patch-Parser-MaxParts @@ -0,0 +1,81 @@ +--- lib/MIME/Parser.pm.orig Tue Aug 31 18:54:05 2004 ++++ lib/MIME/Parser.pm Tue Aug 31 18:53:33 2004 +@@ -250,6 +250,7 @@ + $self->{MP5_IgnoreErrors} = 1; + $self->{MP5_UseInnerFiles} = 0; + $self->{MP5_UUDecode} = 0; ++ $self->{MP5_MaxParts} = -1; + + $self->interface(ENTITY_CLASS => 'MIME::Entity'); + $self->interface(HEAD_CLASS => 'MIME::Head'); +@@ -277,6 +278,7 @@ + $self->{MP5_Filer}->results($self->{MP5_Results}); + $self->{MP5_Filer}->init_parse(); + $self->{MP5_Filer}->purgeable([]); ### just to be safe ++ $self->{MP5_NumParts} = 0; + 1; + } + +@@ -969,11 +980,19 @@ + # Retype => retype this part to the given content-type + # + # Return the entity. +-# Fatal exception on failure. ++# Fatal exception on failure. Returns undef if message to complex + # + sub process_part { + my ($self, $in, $rdr, %p) = @_; + ++ if ($self->{MP5_MaxParts} > 0) { ++ $self->{MP5_NumParts}++; ++ if ($self->{MP5_NumParts} > $self->{MP5_MaxParts}) { ++ # Return UNDEF if msg too complex ++ return undef; ++ } ++ } ++ + $rdr ||= MIME::Parser::Reader->new; + #debug "process_part"; + $self->results->level(+1); +@@ -1094,6 +1112,8 @@ + + Returns the parsed MIME::Entity on success. + Throws exception on failure. ++If the message contained too many ++parts (as set by I<max_parts>), returns undef. + + =cut + +@@ -1351,6 +1371,32 @@ + my $self = shift; + &MIME::Tools::whine("evil_filename deprecated in MIME::Parser"); + $self->filer->evil_filename(@_); ++} ++ ++#------------------------------ ++ ++=item max_parts NUM ++ ++I<Instance method.> ++Limits the number of MIME parts we will parse. ++ ++Normally, instances of this class parse a message to the bitter end. ++Messages with many MIME parts can cause excessive memory consumption. ++If you invoke this method, parsing will abort with a die() if a message ++contains more than NUM parts. ++ ++If NUM is set to -1 (the default), then no maximum limit is enforced. ++ ++With no argument, returns the current setting as an integer ++ ++=cut ++ ++sub max_parts { ++ my($self, $num) = @_; ++ if (@_ > 1) { ++ $self->{MP5_MaxParts} = $num; ++ } ++ return $self->{MP5_MaxParts}; + } + + #------------------------------ |