Lines 939-945
sub _clean_search_term {
Link Here
|
939 |
} |
939 |
} |
940 |
$term = $self->_query_regex_escape_process($term); |
940 |
$term = $self->_query_regex_escape_process($term); |
941 |
|
941 |
|
|
|
942 |
# because of _truncate_terms and if QueryAutoTruncate enabled |
943 |
# we will have any special operators ruined by _truncate_terms: |
944 |
# for ex. search for "test [6 TO 7]" will be converted to "test* [6* TO* 7]" |
945 |
# so no reason to keep ranges in QueryAutoTruncate==true case: |
946 |
my $truncate = C4::Context->preference("QueryAutoTruncate") || 0; |
947 |
unless($truncate) { |
948 |
# replace all ranges with any square/curly brackets combinations to temporary substitutions (ex: "{a TO b]"" -> "~~LC~~a TO b~~RS~~") |
949 |
# (where L is for left and C is for Curly and so on) |
950 |
$term =~ s/ |
951 |
(?<!\\) |
952 |
(?<backslashes>(?:[\\]{2})*) |
953 |
(?<leftbracket>\{|\[) |
954 |
(?<ranges> |
955 |
[^\s\[\]\{\}]+\ TO\ [^\s\[\]\{\}]+ |
956 |
(?<!\\) |
957 |
(?:[\\]{2})* |
958 |
) |
959 |
(?<rightbracket>\}|\]) |
960 |
/$+{backslashes}.'~~L'.($+{leftbracket} eq '[' ? 'S':'C').'~~'.$+{ranges}.'~~R'.($+{rightbracket} eq ']' ? 'S':'C').'~~'/gex; |
961 |
} |
942 |
# save all regex contents away before escaping brackets: |
962 |
# save all regex contents away before escaping brackets: |
|
|
963 |
# (same trick as with brackets above, just RE for 'RegularExpression') |
943 |
my @saved_regexes; |
964 |
my @saved_regexes; |
944 |
my $rgx_i = 0; |
965 |
my $rgx_i = 0; |
945 |
while( |
966 |
while( |
Lines 974-979
sub _clean_search_term {
Link Here
|
974 |
for (my $i = 0; $i < @saved_regexes; $i++) { |
995 |
for (my $i = 0; $i < @saved_regexes; $i++) { |
975 |
$term =~ s/~~RE$i~~/$saved_regexes[$i]/; |
996 |
$term =~ s/~~RE$i~~/$saved_regexes[$i]/; |
976 |
} |
997 |
} |
|
|
998 |
unless($truncate) { |
999 |
# restore temporary weird substitutions back to normal brackets |
1000 |
$term =~ s/~~L(C|S)~~([^\s\[\]\{\}]+ TO [^\s\[\]\{\}]+)~~R(C|S)~~/($1 eq 'S' ? '[':'{').$2.($3 eq 'S' ? ']':'}')/ge; |
1001 |
} |
977 |
return $term; |
1002 |
return $term; |
978 |
} |
1003 |
} |
979 |
|
1004 |
|
980 |
- |
|
|