Skip to content

Commit

Permalink
Another go at resolving static paths
Browse files Browse the repository at this point in the history
  • Loading branch information
tw4l committed Oct 31, 2024
1 parent 9d98cf4 commit 9c1171f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pywb/apps/static_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@ def __call__(self, environ, url_str):
if url.endswith('/'):
url += 'index.html'

# url = sanitize_filepath(url)
url = sanitize_filepath(url)

canonical_static_path = environ.get('pywb.static_dir')
if not canonical_static_path:
canonical_static_path = self.static_path

full_static_path = os.path.abspath(canonical_static_path)
static_path_to_validate = None
full_path = None

if environ.get('pywb.static_dir'):
full_path = os.path.join(full_static_path, url)
full_path = environ.get('pywb.static_dir')
if full_path:
static_path_to_validate = full_path
full_path = os.path.join(full_path, url)
if not os.path.isfile(full_path):
static_path_to_validate = None
full_path = None

if not full_path:
static_path_to_validate = self.static_path
full_path = os.path.join(self.static_path, url)

try:
validate_requested_file_path(full_static_path, full_path)
validate_requested_file_path(static_path_to_validate, full_path)
except PathValidationError:
raise NotFoundException('Static File Not Found: ' +
url_str)
Expand Down

0 comments on commit 9c1171f

Please sign in to comment.