Bug 3955: Fixes leading space error in search.
authorGarry Collum <gcollum@gmail.com>
Fri, 18 Dec 2009 18:52:56 +0000 (13:52 -0500)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Sun, 20 Dec 2009 13:28:48 +0000 (14:28 +0100)
Leading spaces in a search term were causing an error to be thrown in a join operator when auto-truncations is turned on. This patch removes the leading spaces.

C4/Search.pm

index 2fe57ed..e8903fc 100644 (file)
@@ -932,8 +932,10 @@ sub buildQuery {
                 }
 
                 if ($auto_truncation){
-                                       $operand=~join(" ",map{ "$_*" }split (/\s+/,$operand));
-                               }
+                   # join throws an error if there is a leading space
+                   $operand =~ s/^\s+//;
+                  $operand=~join(" ",map{ "$_*" }split (/\s+/,$operand));
+                }
 
                 # Detect Truncation
                 my $truncated_operand;