mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
don't mask raised exceptions, to address #23
This commit is contained in:
parent
1a1aa814d0
commit
d347b4952b
@ -164,34 +164,30 @@ class ReferRedirect:
|
|||||||
if not any (wbrequest.referrer.startswith(i) for i in self.match_prefixs):
|
if not any (wbrequest.referrer.startswith(i) for i in self.match_prefixs):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
ref_split = urlparse.urlsplit(wbrequest.referrer)
|
||||||
|
|
||||||
|
path = ref_split.path
|
||||||
|
script_name = wbrequest.env['SCRIPT_NAME']
|
||||||
|
|
||||||
|
if not path.startswith(script_name):
|
||||||
|
return None
|
||||||
|
|
||||||
|
ref_path = path[len(script_name) + 1:].split('/', 1)
|
||||||
|
|
||||||
|
# No match on any exception
|
||||||
try:
|
try:
|
||||||
ref_split = urlparse.urlsplit(wbrequest.referrer)
|
rewriter = UrlRewriter(ref_path[1], script_name + '/' + ref_path[0] + '/')
|
||||||
|
except Exception:
|
||||||
|
return None
|
||||||
|
|
||||||
path = ref_split.path
|
rel_request_uri = wbrequest.request_uri[1:]
|
||||||
script_name = wbrequest.env['SCRIPT_NAME']
|
|
||||||
|
|
||||||
if not path.startswith(script_name):
|
#ref_wb_url = archiveurl('/' + ref_path[1])
|
||||||
return None
|
#ref_wb_url.url = urlparse.urljoin(ref_wb_url.url, wbrequest.request_uri[1:])
|
||||||
|
#ref_wb_url.url = ref_wb_url.url.replace('../', '')
|
||||||
|
|
||||||
ref_path = path[len(script_name) + 1:].split('/', 1)
|
#final_url = urlparse.urlunsplit((ref_split.scheme, ref_split.netloc, ref_path[0] + str(ref_wb_url), '', ''))
|
||||||
|
final_url = urlparse.urlunsplit((ref_split.scheme, ref_split.netloc, rewriter.rewrite(rel_request_uri), '', ''))
|
||||||
# No match on any exception
|
|
||||||
try:
|
|
||||||
rewriter = UrlRewriter(ref_path[1], script_name + '/' + ref_path[0] + '/')
|
|
||||||
except Exception:
|
|
||||||
return None
|
|
||||||
|
|
||||||
rel_request_uri = wbrequest.request_uri[1:]
|
|
||||||
|
|
||||||
#ref_wb_url = archiveurl('/' + ref_path[1])
|
|
||||||
#ref_wb_url.url = urlparse.urljoin(ref_wb_url.url, wbrequest.request_uri[1:])
|
|
||||||
#ref_wb_url.url = ref_wb_url.url.replace('../', '')
|
|
||||||
|
|
||||||
#final_url = urlparse.urlunsplit((ref_split.scheme, ref_split.netloc, ref_path[0] + str(ref_wb_url), '', ''))
|
|
||||||
final_url = urlparse.urlunsplit((ref_split.scheme, ref_split.netloc, rewriter.rewrite(rel_request_uri), '', ''))
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
raise e
|
|
||||||
|
|
||||||
return WbResponse.redir_response(final_url)
|
return WbResponse.redir_response(final_url)
|
||||||
|
|
||||||
|
@ -195,7 +195,7 @@ class RemoteCDXServer(IndexReader):
|
|||||||
msg = 'Blocked By Robots' if 'Blocked By Robots' in exc_msg else 'Excluded'
|
msg = 'Blocked By Robots' if 'Blocked By Robots' in exc_msg else 'Excluded'
|
||||||
raise wbexceptions.AccessException(msg)
|
raise wbexceptions.AccessException(msg)
|
||||||
else:
|
else:
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
if parsed_cdx:
|
if parsed_cdx:
|
||||||
return (CDXCaptureResult(cdx) for cdx in response)
|
return (CDXCaptureResult(cdx) for cdx in response)
|
||||||
|
@ -89,9 +89,9 @@ def main():
|
|||||||
logging.info('*** pywb inited with settings from {0}.pywb_config()!\n'.format(config_name))
|
logging.info('*** pywb inited with settings from {0}.pywb_config()!\n'.format(config_name))
|
||||||
return app
|
return app
|
||||||
|
|
||||||
except Exception as e:
|
except Exception:
|
||||||
logging.exception('*** pywb could not init with settings from {0}.pywb_config()!\n'.format(config_name))
|
logging.exception('*** pywb could not init with settings from {0}.pywb_config()!\n'.format(config_name))
|
||||||
raise e
|
raise
|
||||||
|
|
||||||
#=================================================================
|
#=================================================================
|
||||||
if __name__ == "__main__" or utils.enable_doctests():
|
if __name__ == "__main__" or utils.enable_doctests():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user