Skip to content

Commit

Permalink
Item8644: prevent altering the token value
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@6589 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
ArthurClemens authored and ArthurClemens committed Feb 28, 2010
1 parent 6cfd3a8 commit b1c7ae6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions core/lib/Foswiki/Store/SearchAlgorithms/Forking.pm
Expand Up @@ -149,15 +149,17 @@ sub query {
# AND search - search once for each token, ANDing result together
foreach my $token ( @{ $query->{tokens} } ) {

my $tokenCopy = $token;

# flag for AND NOT search
my $invertSearch = 0;
$invertSearch = ( $token =~ s/^\!//o );
$invertSearch = ( $tokenCopy =~ s/^\!//o );

# scope can be 'topic' (default), 'text' or "all"
# scope='topic', e.g. Perl search on topic name:
my %topicMatches;
unless ( $options->{'scope'} eq 'text' ) {
my $qtoken = $token;
my $qtoken = $tokenCopy;

# FIXME I18N
# http://foswiki.org/Tasks/Item1646 this causes us to use/leak huge amounts of memory if called too often
Expand Down Expand Up @@ -186,7 +188,7 @@ sub query {
my $textMatches;
unless ( $options->{'scope'} eq 'topic' ) {
$textMatches = search(
$token, $web, $topicSet, $session, $options );
$tokenCopy, $web, $topicSet, $session, $options );
}

#bring the text matches into the topicMatch hash
Expand Down
8 changes: 5 additions & 3 deletions core/lib/Foswiki/Store/SearchAlgorithms/PurePerl.pm
Expand Up @@ -99,15 +99,17 @@ sub query {
# AND search - search once for each token, ANDing result together
foreach my $token ( @{ $query->{tokens} } ) {

my $tokenCopy = $token;

# flag for AND NOT search
my $invertSearch = 0;
$invertSearch = ( $token =~ s/^\!//o );
$invertSearch = ( $tokenCopy =~ s/^\!//o );

# scope can be 'topic' (default), 'text' or "all"
# scope='topic', e.g. Perl search on topic name:
my %topicMatches;
unless ( $options->{'scope'} eq 'text' ) {
my $qtoken = $token;
my $qtoken = $tokenCopy;
# FIXME I18N
$qtoken = quotemeta($qtoken)
if ( $options->{'type'} ne 'regex' );
Expand All @@ -132,7 +134,7 @@ sub query {
my $textMatches;
unless ( $options->{'scope'} eq 'topic' ) {
$textMatches = search(
$token, $web, $topicSet, $session->{store}, $options );
$tokenCopy, $web, $topicSet, $session->{store}, $options );
}

#bring the text matches into the topicMatch hash
Expand Down

0 comments on commit b1c7ae6

Please sign in to comment.