From: miker Date: Tue, 16 Feb 2010 15:40:36 +0000 (+0000) Subject: Backporting 15547: ARG! attempted support for search term containing colons ended... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=fdb46389c2b4093b78196eaf5184c5839405615a;p=working%2FEvergreen.git Backporting 15547: ARG! attempted support for search term containing colons ended up breaking multiclass searching git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6@15548 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm index 1a1329707a..a9b7048e9e 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm @@ -563,12 +563,28 @@ sub multiclass_query { $logger->debug("cleansed query string => $query"); my $search = $arghash->{searches} = {}; - while ($query =~ s/((?:keyword(?:\|\w+)?|title(?:\|\w+)?|author(?:\|\w+)?|subject(?:\|\w+)?|series(?:\|\w+)?|site|dir|sort|lang|available):.+?)$//so) { + my $simple_class_re = qr/((?:\w+(?:\|\w+)?):[^:]+?)$/; + my $class_list_re = qr/(?:keyword|title|author|subject|series)/; + my $modifier_list_re = qr/(?:site|dir|sort|lang|available)/; + + my $tmp_value = ''; + while ($query =~ s/($simple_class_re[^:]+?)$//so) { + my $qpart = $1; my $where = index($qpart,':'); my $type = substr($qpart, 0, $where++); my $value = substr($qpart, $where); + if ($type !~ /^(?:$class_list_re|$modifier_list_re)/o) { + $tmp_value = "$qpart $tmp_value"; + next; + } + + if ($type =~ /$class_list_re/o ) { + $value .= $tmp_value; + $tmp_value = ''; + } + next unless $type and $value; $value =~ s/^\s*//og; @@ -607,8 +623,11 @@ sub multiclass_query { } } + $query .= " $tmp_value"; + if($query) { - # This is the front part of the string before any special tokens were parsed. + # This is the front part of the string before any special tokens were + # parsed OR colon-separated strings that do not denote a class. # Add this data to the default search class my $type = $arghash->{default_class} || 'keyword'; $type = ($type eq '-') ? 'keyword' : $type;