Bugzilla – Attachment 114058 Details for
Bug 26578
OverDrive results can return false positives when searches contain CCL syntax
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26578: Clean overdrive searches before passing to OD
Bug-26578-Clean-overdrive-searches-before-passing-.patch (text/plain), 3.45 KB, created by
Nick Clemens
on 2020-11-30 14:28:33 UTC
(
hide
)
Description:
Bug 26578: Clean overdrive searches before passing to OD
Filename:
MIME Type:
Creator:
Nick Clemens
Created:
2020-11-30 14:28:33 UTC
Size:
3.45 KB
patch
obsolete
>From cd9e8b2263bcbe93efe1b010322bebce2251f81d Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 30 Sep 2020 12:52:28 +0000 >Subject: [PATCH] Bug 26578: Clean overdrive searches before passing to OD > >This patch copies regex used in buildQuery to detect ccl code in queries, but here we adapt >it to remove any ccl signifiers to ensure correct results from OD > >To test: >1 - Have OverDrive enabled and configured >2 - set UseAuthoritiesForTracings to "Don't use" >3 - Search in the catalog for a record >4 - From the details page for a record click on an author link >5 - Note the query in catalog is like 'au:"Whitford, Bradley."' >6 - Some overdrive catalogs will return records matching 'au:' >7 - Apply patch >8 - Reload the page, if there were spurious results before, they should now be gone >9 - Perform a search that returns overdrive results >10 - For a title in overdrive search koha with: > au:{Author} AND ti:{Title} >11 - Confirm overdrive results are returned >12 - Check the link to overdrive results and note query section is: > q=Author AND Title >--- > koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >index 34b27c0ccd..be8019f107 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >@@ -914,14 +914,19 @@ > var $overdrive_results = $( '<div id="overdrive-results">' + MSG_SEARCHING.format('OverDrive') + ' <img class="throbber" src="[% interface | html %]/lib/jquery/plugins/themes/classic/throbber.gif" /></div>' ); > $( '#numresults' ) .append( ' ' ) > .append( $overdrive_results ); >- KOHA.OverDrive.Search( "[% Koha.Preference('OverDriveLibraryID') | html %]", querystring, 1, 0, function( data ) { >+ //Clean querystring, first we remove CCL entities, then decode HTML entities, then swap double quotes for single quotes >+ //as the overdrive API treats double quotes as a search term and returns extra results >+ od_querystring = querystring.replace(/(?:^|\W)([\w-]+)(,[\w-]+)*([:=])/g,' '); >+ od_querystring = new DOMParser().parseFromString( od_querystring, 'text/html').body.innerText; >+ od_querystring = od_querystring.replace(/\"/g,"'"); >+ KOHA.OverDrive.Search( "[% Koha.Preference('OverDriveLibraryID') | html %]", od_querystring, 1, 0, function( data ) { > if ( data.error ) { > $overdrive_results.html( MSG_ERROR_SEARCHING_COLLECTION.format('OverDrive') ); > return; > } > > if ( data.totalItems ) { >- $overdrive_results.html( '<a href="/cgi-bin/koha/opac-overdrive-search.pl?q=' + escape( querystring ) + '">' + MSG_RESULTS_FOUND_IN_COLLECTION.format(data.totalItems, 'OverDrive') + '</a>' ); >+ $overdrive_results.html( '<a href="/cgi-bin/koha/opac-overdrive-search.pl?q=' + escape( od_querystring ) + '">' + MSG_RESULTS_FOUND_IN_COLLECTION.format(data.totalItems, 'OverDrive') + '</a>' ); > } else { > $overdrive_results.remove(); > } >-- >2.11.0
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 26578
:
110987
|
113923
|
114058
|
114098
|
116014