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

Another go at resolving static paths

This commit is contained in:
Tessa Walsh 2024-10-31 12:50:21 -04:00
parent 9d98cf48ce
commit 9c1171fb11

View File

@ -30,25 +30,25 @@ class StaticHandler(object):
if url.endswith('/'): if url.endswith('/'):
url += 'index.html' url += 'index.html'
# url = sanitize_filepath(url) url = sanitize_filepath(url)
canonical_static_path = environ.get('pywb.static_dir') static_path_to_validate = None
if not canonical_static_path:
canonical_static_path = self.static_path
full_static_path = os.path.abspath(canonical_static_path)
full_path = None full_path = None
if environ.get('pywb.static_dir'): full_path = environ.get('pywb.static_dir')
full_path = os.path.join(full_static_path, url) if full_path:
static_path_to_validate = full_path
full_path = os.path.join(full_path, url)
if not os.path.isfile(full_path): if not os.path.isfile(full_path):
static_path_to_validate = None
full_path = None full_path = None
if not full_path: if not full_path:
static_path_to_validate = self.static_path
full_path = os.path.join(self.static_path, url) full_path = os.path.join(self.static_path, url)
try: try:
validate_requested_file_path(full_static_path, full_path) validate_requested_file_path(static_path_to_validate, full_path)
except PathValidationError: except PathValidationError:
raise NotFoundException('Static File Not Found: ' + raise NotFoundException('Static File Not Found: ' +
url_str) url_str)