ignore and if written any other way than AND
[webpac2] / vhost / webpac2.cgi
index 5e4ac0e..fd76b65 100755 (executable)
@@ -234,6 +234,9 @@ if ( my $search = param('search') ) {
                                   $template =~ s{Q}{$v};
                                $whitespace = " AND " if $whitespace;
 
+                               # don't return -* &* and other non-word characters
+                               return '' if $template =~ m/^\W\*$/ || $template =~ m/\band\b/i;
+
                                return
                                        $whitespace .
                                        $attr . '="' . $template . '"';
@@ -262,7 +265,11 @@ if ( my $search = param('search') ) {
        $q .= ' AND ((' . join(') OR (', map { "input=\"$_\"" } @only_input) . '))' if @only_input;
 
        warn "# query: $q\n";
-       my $swish_results = $swish->query( $q );
+       my $search_obj = $swish->new_search_object;
+       if ( my $sort = param('sort') ) {
+               $search_obj->set_sort( $sort );
+       }
+       my $swish_results = $search_obj->execute( $q );
 
        dump_yaml( 'swish_results', $swish_results );