From 84081cc3b5287f925ffeeb94ae730e4c143b5f59 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 26 Feb 2023 17:40:39 -0400 Subject: encode/decode URIs in html.tag('a') & live-dev-server Fixes #147. --- src/write/build-modes/live-dev-server.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/write') diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js index 39229a9a..a8fd3705 100644 --- a/src/write/build-modes/live-dev-server.js +++ b/src/write/build-modes/live-dev-server.js @@ -163,7 +163,15 @@ export async function go({ localDirectory = mediaPath; } - const filePath = path.resolve(localDirectory, safePath.split('/').join(path.sep)); + let filePath; + try { + filePath = path.resolve(localDirectory, decodeURI(safePath.split('/').join(path.sep))); + } catch (error) { + response.writeHead(404, contentTypePlain); + response.end(`No ${localFileArea} file found for: ${safePath}`); + console.log(`${requestHead} [404] ${pathname}`); + console.log(`Failed to decode request pathname`); + } try { await stat(filePath); -- cgit 1.3.0-6-gf8a5