View | Details | Raw Unified | Return to bug 28316
Collapse All | Expand All

(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (-1 / +18 lines)
Lines 938-943 sub _clean_search_term { Link Here
938
    }
938
    }
939
    $term = $self->_query_regex_escape_process($term);
939
    $term = $self->_query_regex_escape_process($term);
940
940
941
    # save all regex contents away before escaping brackets:
942
    my @saved_regexes;
943
    my $rgx_i = 0;
944
    while(
945
            $term =~ s@(
946
                (?<!\\)(?:[\\]{2})*/
947
                (?:[^/]+|(?<=\\)(?:[\\]{2})*/)+
948
                (?<!\\)(?:[\\]{2})*/
949
            )$lookahead@"~~XI$rgx_i~~"@ex
950
    ) {
951
        @saved_regexes[$rgx_i++] = $1;
952
    }
953
941
    # remove leading and trailing colons mixed with optional slashes and spaces
954
    # remove leading and trailing colons mixed with optional slashes and spaces
942
    $term =~ s/^([\s\\]*:\s*)+//;
955
    $term =~ s/^([\s\\]*:\s*)+//;
943
    $term =~ s/([\s\\]*:\s*)+$//;
956
    $term =~ s/([\s\\]*:\s*)+$//;
Lines 955-960 sub _clean_search_term { Link Here
955
968
956
    # screen all brackets with backslash
969
    # screen all brackets with backslash
957
    $term =~ s/(?<!\\)(?:[\\]{2})*([\{\}\[\]])$lookahead/\\$1/g;
970
    $term =~ s/(?<!\\)(?:[\\]{2})*([\{\}\[\]])$lookahead/\\$1/g;
971
972
    # restore all regex contents after escaping brackets:
973
    for (my $i = 0; $i < @saved_regexes; $i++) {
974
        $term =~ s/~~XI$i~~/$saved_regexes[$i]/;
975
    }
958
    return $term;
976
    return $term;
959
}
977
}
960
978
961
- 

Return to bug 28316