diff options
author | Max Kanat-Alexander <mkanat@bugzilla.org> | 2011-04-02 11:57:14 -0700 |
---|---|---|
committer | Max Kanat-Alexander <mkanat@bugzilla.org> | 2011-04-02 11:57:14 -0700 |
commit | e1c91cd842cc2193309a284b3bd49488342ca8a1 (patch) | |
tree | 5aa390a757664b0be99ca17817ed35fd4782c3b4 /Bugzilla/Search/Clause.pm | |
parent | d5c5177f2ef698aefa8aeffaa458016583c20f79 (diff) | |
download | bugs-e1c91cd842cc2193309a284b3bd49488342ca8a1.tar bugs-e1c91cd842cc2193309a284b3bd49488342ca8a1.tar.gz bugs-e1c91cd842cc2193309a284b3bd49488342ca8a1.tar.bz2 bugs-e1c91cd842cc2193309a284b3bd49488342ca8a1.tar.xz bugs-e1c91cd842cc2193309a284b3bd49488342ca8a1.zip |
Bug 647466: Allow Search.pm to take the new URL syntax for custom search
r=mkanat, a=mkanat (module owner)
Diffstat (limited to 'Bugzilla/Search/Clause.pm')
-rw-r--r-- | Bugzilla/Search/Clause.pm | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/Bugzilla/Search/Clause.pm b/Bugzilla/Search/Clause.pm index e31bfdd40..aa87842af 100644 --- a/Bugzilla/Search/Clause.pm +++ b/Bugzilla/Search/Clause.pm @@ -21,10 +21,18 @@ package Bugzilla::Search::Clause; use strict; + +use Bugzilla::Error; use Bugzilla::Search::Condition qw(condition); +use Bugzilla::Util qw(trick_taint); sub new { my ($class, $joiner) = @_; + if ($joiner and $joiner ne 'OR' and $joiner ne 'AND') { + ThrowCodeError('search_invalid_joiner', { joiner => $joiner }); + } + # This will go into SQL directly so needs to be untainted. + trick_taint($joiner) if $joiner; bless { joiner => $joiner || 'AND' }, $class; } @@ -41,12 +49,14 @@ sub has_children { return scalar(@{ $self->children }) > 0 ? 1 : 0; } -sub has_conditions { +sub has_valid_conditions { my ($self) = @_; my $children = $self->children; - return 1 if grep { $_->isa('Bugzilla::Search::Condition') } @$children; + return 1 if grep { $_->isa('Bugzilla::Search::Condition') + && $_->translated } @$children; foreach my $child (@$children) { - return 1 if $child->has_conditions; + next if $child->isa('Bugzilla::Search::Condition'); + return 1 if $child->has_valid_conditions; } return 0; } @@ -69,7 +79,7 @@ sub add { sub negate { my ($self, $value) = @_; if (@_ == 2) { - $self->{negate} = $value; + $self->{negate} = $value ? 1 : 0; } return $self->{negate}; } @@ -90,7 +100,7 @@ sub as_string { my ($self) = @_; my @strings; foreach my $child (@{ $self->children }) { - next if $child->isa(__PACKAGE__) && !$child->has_conditions; + next if $child->isa(__PACKAGE__) && !$child->has_valid_conditions; next if $child->isa('Bugzilla::Search::Condition') && !$child->translated; |