1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 00:03:28 +01:00

don't mask raised exceptions, to address #23

This commit is contained in:
Ilya Kreymer 2014-02-05 13:21:57 -08:00
parent 1a1aa814d0
commit d347b4952b
3 changed files with 23 additions and 27 deletions

View File

@ -164,34 +164,30 @@ class ReferRedirect:
if not any (wbrequest.referrer.startswith(i) for i in self.match_prefixs):
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:
ref_split = urlparse.urlsplit(wbrequest.referrer)
rewriter = UrlRewriter(ref_path[1], script_name + '/' + ref_path[0] + '/')
except Exception:
return None
path = ref_split.path
script_name = wbrequest.env['SCRIPT_NAME']
rel_request_uri = wbrequest.request_uri[1:]
if not path.startswith(script_name):
return None
#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('../', '')
ref_path = path[len(script_name) + 1:].split('/', 1)
# 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
#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), '', ''))
return WbResponse.redir_response(final_url)

View File

@ -195,7 +195,7 @@ class RemoteCDXServer(IndexReader):
msg = 'Blocked By Robots' if 'Blocked By Robots' in exc_msg else 'Excluded'
raise wbexceptions.AccessException(msg)
else:
raise e
raise
if parsed_cdx:
return (CDXCaptureResult(cdx) for cdx in response)

View File

@ -89,9 +89,9 @@ def main():
logging.info('*** pywb inited with settings from {0}.pywb_config()!\n'.format(config_name))
return app
except Exception as e:
except Exception:
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():