Bug 12593: search facets die with regex error if biblio has square brackets in fields

It's quite common to have [something] within facet data, and it produces following error:

Unmatched [ in regex; marked by <-- HERE in m/^[ <-- HERE

This problem was intoduced in Bug 12151 but is trivial to fix.

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Good catch.

To test:
- Created a bibliographic record, linked to an authority record (personal name). Did a search that returned the author as a facet.
- Added a [ symbol to the author name.
- Repeated the search
=> FAIL: "Unmatched [ in regex; marked by <-- HERE in m/^[ <-- HERE"
- Apply the patch
- Retry the search
=> SUCCESS: No error, bracket shows correctly.

Passes koha-qa.pl too.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
Dobrica Pavlinusic 2014-07-17 12:27:55 +02:00 committed by Galen Charlton
parent a67bce36b0
commit 7f6f09da96
1 changed files with 1 additions and 1 deletions

View File

@ -532,7 +532,7 @@ sub getRecords {
foreach my $field (@fields) {
my $data = $field->as_string( $subfield_letters, $facet->{sep} );
unless ( grep { /^$data$/ } @used_datas ) {
unless ( grep { /^\Q$data\E$/ } @used_datas ) {
push @used_datas, $data;
$facets_counter->{ $facet->{idx} }->{$data}++;
}