[LON-CAPA-cvs] cvs: loncom /interface lonsearchcat.pm

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 03 May 2004 19:24:14 -0000


matthew		Mon May  3 15:24:14 2004 EDT

  Modified files:              
    /loncom/interface	lonsearchcat.pm 
  Log:
  Bug 2940: Searching for just 'AND', 'OR', or 'NOT' caused internal server
  error.  Now it just causes the usual obtuse error message.
  
  
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.219 loncom/interface/lonsearchcat.pm:1.220
--- loncom/interface/lonsearchcat.pm:1.219	Fri Apr 30 17:28:07 2004
+++ loncom/interface/lonsearchcat.pm	Mon May  3 15:24:14 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.219 2004/04/30 21:28:07 matthew Exp $
+# $Id: lonsearchcat.pm,v 1.220 2004/05/03 19:24:14 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1161,6 +1161,7 @@
 		   'lastrevisiondatestart_year','lastrevisiondateend_month',
 		   'lastrevisiondateend_day','lastrevisiondateend_year') {
 	$ENV{'form.'.$field}=~s/[^\w\/\s\(\)\=\-\"\']//g;
+        $ENV{'form.'.$field}=~s/(not\s*$|^\s*(and|or)|)//gi;
     }
     foreach ('mode','form','element') {
 	# is this required?  Hmmm.
@@ -1425,12 +1426,13 @@
         &parse_domain_restrictions();
     #
     # Check to see if enough of a query is filled in
-    unless (&filled($ENV{'form.basicexp'})) {
+    my $search_string = $ENV{'form.basicexp'};
+    $search_string =~ s/(not\s*$|^\s*(and|or)|)//gi;
+    if (! &filled($search_string)) {
 	&output_blank_field_error($r,$closebutton,'phase=disp_basic');
 	return OK;
     }
     my $pretty_search_string = '<b>'.$ENV{'form.basicexp'}.'</b>';
-    my $search_string = $ENV{'form.basicexp'};
     if ($ENV{'form.related'}) {
         my @New_Words;
         ($search_string,@New_Words) = &related_version($ENV{'form.basicexp'});