webserver: Unquote urls containing quoted characters.

- e.g. Caused by filenames containing spaces.
This commit is contained in:
Andrew Hamilton 2021-11-18 21:35:59 +10:00
parent ae7f53a1fc
commit 2e44fa42dc

View file

@ -6,8 +6,9 @@ import functools
import gzip import gzip
import http.server import http.server
import os import os
import sys
import pickle import pickle
import sys
import urllib.parse
import eris.tools as tools import eris.tools as tools
import fill3 import fill3
@ -50,7 +51,8 @@ def make_main_body():
@functools.lru_cache(maxsize=100) @functools.lru_cache(maxsize=100)
def make_listing_page(url_path): def make_listing_page(url_path):
path, tool = os.path.split(url_path) unquoted_path = urllib.parse.unquote(url_path)
path, tool = os.path.split(unquoted_path)
result = index[(path, tool)] result = index[(path, tool)]
body = fill3.appearance_as_html(result.appearance_min()) body = fill3.appearance_as_html(result.appearance_min())
return make_page(body, f"{tool} of {path}") return make_page(body, f"{tool} of {path}")