Bugzilla – Attachment 83959 Details for
Bug 13937
Add an Elasticsearch-compatible Z39.50/SRU daemon
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13937: Fix RPN conversion
Bug-13937-Fix-RPN-conversion.patch (text/plain), 3.20 KB, created by
Ere Maijala
on 2019-01-15 11:56:41 UTC
(
hide
)
Description:
Bug 13937: Fix RPN conversion
Filename:
MIME Type:
Creator:
Ere Maijala
Created:
2019-01-15 11:56:41 UTC
Size:
3.20 KB
patch
obsolete
>From ac7014f2623900374cc20d7fb286009791897028 Mon Sep 17 00:00:00 2001 >From: Ere Maijala <ere.maijala@helsinki.fi> >Date: Tue, 15 Jan 2019 13:54:17 +0200 >Subject: [PATCH] Bug 13937: Fix RPN conversion > >Fixes handling of quotes and parenthesis. >--- > Koha/Z3950Responder/RPN.pm | 22 ++++++++++++------- > .../Koha/Z3950Responder/GenericSession.t | 4 ++-- > 2 files changed, 16 insertions(+), 10 deletions(-) > >diff --git a/Koha/Z3950Responder/RPN.pm b/Koha/Z3950Responder/RPN.pm >index ea8ca37f98..377c5e3d0d 100644 >--- a/Koha/Z3950Responder/RPN.pm >+++ b/Koha/Z3950Responder/RPN.pm >@@ -71,9 +71,10 @@ sub to_koha { > $word =~ s/^[\,\.;:\\\/\"\'\-\=]+//g; > $word =~ s/[\,\.;:\\\/\"\'\-\=]+$//g; > next if (!$word); >+ $word = $self->escape($word); > my @words; > foreach my $field (@{$fields}) { >- push(@words, "$field:($prefix$word$suffix)"); >+ push(@words, "$field:($quote$prefix$word$suffix$quote)"); > } > push (@terms, join(' OR ', @words)); > } >@@ -81,15 +82,22 @@ sub to_koha { > } > > my @terms; >+ $term = $self->escape($term); > foreach my $field (@{$fields}) { >- push(@terms, "$field:($prefix$term$suffix)"); >+ push(@terms, "$field:($quote$prefix$term$suffix$quote)"); > } > return '(' . join(' OR ', @terms) . ')'; > } > >+sub escape { >+ my ($self, $term) = @_; >+ >+ $term =~ s/([()])/\\$1/g; >+ return $term; >+} >+ > package Net::Z3950::RPN::And; >-sub to_koha >-{ >+sub to_koha { > my ($self, $mappings) = @_; > > return '(' . $self->[0]->to_koha($mappings) . ' AND ' . >@@ -97,8 +105,7 @@ sub to_koha > } > > package Net::Z3950::RPN::Or; >-sub to_koha >-{ >+sub to_koha { > my ($self, $mappings) = @_; > > return '(' . $self->[0]->to_koha($mappings) . ' OR ' . >@@ -106,8 +113,7 @@ sub to_koha > } > > package Net::Z3950::RPN::AndNot; >-sub to_koha >-{ >+sub to_koha { > my ($self, $mappings) = @_; > > return '(' . $self->[0]->to_koha($mappings) . ' NOT ' . >diff --git a/t/db_dependent/Koha/Z3950Responder/GenericSession.t b/t/db_dependent/Koha/Z3950Responder/GenericSession.t >index 164f53e059..c1bb131cea 100644 >--- a/t/db_dependent/Koha/Z3950Responder/GenericSession.t >+++ b/t/db_dependent/Koha/Z3950Responder/GenericSession.t >@@ -68,7 +68,7 @@ subtest 'test_search' => sub { > $search->mock('simple_search_compat', sub { > my ( $self, $query ) = @_; > >- return (1, undef, 0) unless $query eq '((author:(author)) AND (title:(title)))'; >+ return (1, undef, 0) unless $query eq '((author:("author")) AND ((title:(title\(s\))) OR (title:(another))))'; > > my @records = ($marc_record_1, $marc_record_2); > return (undef, \@records, 2); >@@ -97,7 +97,7 @@ subtest 'test_search' => sub { > $Zconn->connect('127.0.0.1:42111', 0); > is($Zconn->errcode(), 0, 'Connection is successful: ' . $Zconn->errmsg()); > >- my $rs = $Zconn->search_pqf('@and @attr 1=1 author @attr 1=4 title'); >+ my $rs = $Zconn->search_pqf('@and @attr 1=1 @attr 4=1 author @or @attr 1=4 title(s) @attr 1=4 another'); > is($Zconn->errcode(), 0, 'Search is successful: ' . $Zconn->errmsg()); > > is($rs->size(), 2, 'Two results returned'); >-- >2.17.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13937
:
46369
|
47417
|
47418
|
47419
|
53503
|
58122
|
58125
|
58126
|
59443
|
59444
|
60735
|
60736
|
60737
|
60738
|
66943
|
66944
|
66945
|
66946
|
69139
|
82562
|
82563
|
82564
|
82565
|
82566
|
82567
|
82589
|
82590
|
82591
|
82592
|
82593
|
82594
|
82595
|
82660
|
82661
|
82662
|
82663
|
82664
|
82665
|
82666
|
82667
|
83780
|
83781
|
83782
|
83783
|
83784
|
83785
|
83786
|
83787
|
83788
|
83789
|
83951
|
83952
|
83953
|
83954
|
83955
|
83956
|
83957
|
83958
|
83959
|
84050
|
84051
|
84052
|
84053
|
84054
|
84055
|
84056
|
84057
|
84058
|
84059
|
84062
|
84063
|
84064
|
84065
|
84066
|
84067
|
84068
|
84069
|
84072
|
84073
|
85112
|
86353
|
86354
|
86355
|
86356
|
86357
|
86358
|
86359
|
86360
|
86361
|
86362
|
86363
|
86364
|
88907
|
88908
|
88909
|
88910
|
88911
|
88912
|
88913
|
88914
|
88915
|
88916
|
88917
|
88918
|
91728
|
91729
|
91730
|
91731
|
91732
|
91733
|
91734
|
91735
|
91736
|
91737
|
91738
|
91739
|
91740
|
93913
|
94097
|
94109
|
94110
|
94209
|
94616
|
94647