*** lib/TWiki/Search.pm.orig 2008-04-10 19:00:05.000000000 -0400 --- lib/TWiki/Search.pm 2008-05-10 09:40:17.000000000 -0400 *************** *** 578,583 **** --- 578,586 ---- # Split the search string into tokens depending on type of search - # each token is ANDed together by actual search my @tokens = $this->_tokensFromSearchString( $searchString, $type ); + # CLIF: convert tokens (back) into pattern + my $searchExpression = join("|" , @tokens); + my $searchEscaped = join("\%VBAR\%", @tokens); # Write log entry # FIXME: Move log entry further down to log actual webs searched *************** *** 819,825 **** $out =~ s/\$parent\(([^\)]*)\)/TWiki::Render::breakName( $meta->getParent(), $1 )/ges; $out =~ s/\$parent/$meta->getParent()/ges; $out =~ s/\$formname/$meta->getFormName()/ges; ! $out =~ s/\$count\((.*?\s*\.\*)\)/_countPattern( $text, $1 )/ges; # FIXME: Allow all regex characters but escape them # Note: The RE requires a .* at the end of a pattern to avoid false positives # in pattern matching --- 822,831 ---- $out =~ s/\$parent\(([^\)]*)\)/TWiki::Render::breakName( $meta->getParent(), $1 )/ges; $out =~ s/\$parent/$meta->getParent()/ges; $out =~ s/\$formname/$meta->getFormName()/ges; ! # CLIF: modified count, added two lines to return search pattern or count in context ! $out =~ s/\$count\((.*?\s*\.\*)\)/_countPattern( $text, $1, $caseSensitive )/ges; ! $out =~ s/\$searchpattern/$searchEscaped/gs; ! $out =~ s/\$countcontext\(\(([^)]*)\)\(([^)]*)\)\)/_countPattern( $text, ".*?${1}($searchExpression)${2}.*", $caseSensitive)/ges; # FIXME: Allow all regex characters but escape them # Note: The RE requires a .* at the end of a pattern to avoid false positives # in pattern matching *************** *** 1100,1106 **** # With the same argument as $pattern, returns a number which is the count of # occurences of the pattern argument. sub _countPattern { ! my( $theText, $thePattern ) = @_; $thePattern =~ s/([^\\])([\$\@\%\&\#\'\`\/])/$1\\$2/go; # escape some special chars $thePattern =~ /(.*)/; # untaint --- 1106,1112 ---- # With the same argument as $pattern, returns a number which is the count of # occurences of the pattern argument. sub _countPattern { ! my( $theText, $thePattern, $caseSensitive ) = @_; $thePattern =~ s/([^\\])([\$\@\%\&\#\'\`\/])/$1\\$2/go; # escape some special chars $thePattern =~ /(.*)/; # untaint *************** *** 1108,1114 **** my $OK = 0; eval { # counting hack, see: http://dev.perl.org/perl6/rfc/110.html ! $OK = () = $theText =~ /$thePattern/g; }; return $OK; --- 1114,1124 ---- my $OK = 0; eval { # counting hack, see: http://dev.perl.org/perl6/rfc/110.html ! if ($caseSensitive) { ! $OK = () = $theText =~ /$thePattern/g; ! } else { ! $OK = () = $theText =~ /$thePattern/gi; ! } }; return $OK;