From c00f30e8971f781d1ec91369a17fc7cdaa07e0f3 Mon Sep 17 00:00:00 2001 From: Andy Jackson Date: Wed, 27 Feb 2019 15:01:33 +0000 Subject: [PATCH] Double-quoting XmlQueryIndexSource lookups for #29 The OpenWayback reference implementation of this API relies on doubly-escaped queries. This change should bring this implementation into line with OutbackCDX and OWB's original API. --- pywb/warcserver/index/indexsource.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pywb/warcserver/index/indexsource.py b/pywb/warcserver/index/indexsource.py index 121b2e99..b6c61b87 100644 --- a/pywb/warcserver/index/indexsource.py +++ b/pywb/warcserver/index/indexsource.py @@ -222,8 +222,6 @@ class RemoteIndexSource(BaseIndexSource): # ============================================================================= class XmlQueryIndexSource(BaseIndexSource): - EXACT_SUFFIX = '?q=type:urlquery+url:{url}' - PREFIX_SUFFIX = '?q=type:prefixquery+url:{url}' def __init__(self, query_api_url): self.query_api_url = query_api_url @@ -237,14 +235,12 @@ class XmlQueryIndexSource(BaseIndexSource): matchType = params.get('matchType', 'exact') if matchType == 'exact': - query_url = self.query_api_url + self.EXACT_SUFFIX + query_url = self.query_api_url + '?q=' + quote_plus('type:urlquery+url:' + quote_plus(url)) elif matchType == 'prefix': - query_url = self.query_api_url + self.PREFIX_SUFFIX + query_url = self.query_api_url + '?q=' + quote_plus('type:prefixquery+url:' + quote_plus(url)) else: raise BadRequestException('matchType={0} is not supported'.format(matchType=matchType)) - query_url = query_url.format(url=quote_plus(url)) - try: response = self.session.get(query_url) response.raise_for_status()