You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by fe...@apache.org on 2006/06/26 05:28:43 UTC
svn commit: r417119 -
/spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm
Author: felicity
Date: Sun Jun 25 20:28:43 2006
New Revision: 417119
URL: http://svn.apache.org/viewvc?rev=417119&view=rev
Log:
bug 4969: make the recursive option to find_parts() useful by allowing recursion into direct children but not go further, fixing the old version which only looked at the single part
Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm?rev=417119&r1=417118&r2=417119&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Message/Node.pm Sun Jun 25 20:28:43 2006
@@ -86,7 +86,8 @@
tree (ie: parts that aren't multipart), set this to true (1).
Recursive - By default, when find_parts() finds a multipart which has
-parts underneath it, it will recurse.
+parts underneath it, it will recurse through all sub-children. If set to 0,
+only look at the part and any direct children of the part.
=cut
@@ -101,16 +102,20 @@
return () unless $re;
$onlyleaves = 0 unless defined $onlyleaves;
- $recursive = 1 unless defined $recursive;
+
+ my $depth;
+ if (defined $recursive && $recursive == 0) {
+ $depth = 1;
+ }
- return $self->_find_parts($re, $onlyleaves, $recursive);
+ return $self->_find_parts($re, $onlyleaves, $depth);
}
# We have 2 functions in find_parts() to optimize out the penalty of
# $onlyleaves, $re, and $recursive over and over again.
#
sub _find_parts {
- my ($self, $re, $onlyleaves, $recursive) = @_;
+ my ($self, $re, $onlyleaves, $depth) = @_;
my @ret = ();
# If this object matches, mark it for return.
@@ -120,11 +125,13 @@
push(@ret, $self);
}
- if ( $recursive && !$amialeaf ) {
+ if ( !$amialeaf && (!defined $depth || $depth > 0)) {
+ $depth-- if defined $depth;
+
# This object is a subtree root. Search all children.
foreach my $parts ( @{$self->{'body_parts'}} ) {
# Add the recursive results to our results
- push(@ret, $parts->_find_parts($re, $onlyleaves, 1));
+ push(@ret, $parts->_find_parts($re, $onlyleaves, $depth));
}
}