From 83215924081198b7b4cd95a89046a4527951fc68 Mon Sep 17 00:00:00 2001 From: Sean Lynch Date: Tue, 19 Sep 2023 08:18:29 -0400 Subject: [PATCH] Escape paths when passing them to globs Try to prevent JS search from breaking on pathnames with square brackets. --- server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index d0406049..b2e16716 100644 --- a/server.py +++ b/server.py @@ -132,12 +132,12 @@ class PromptServer(): @routes.get("/extensions") async def get_extensions(request): files = glob.glob(os.path.join( - self.web_root, 'extensions/**/*.js'), recursive=True) + glob.escape(self.web_root), 'extensions/**/*.js'), recursive=True) extensions = list(map(lambda f: "/" + os.path.relpath(f, self.web_root).replace("\\", "/"), files)) for name, dir in nodes.EXTENSION_WEB_DIRS.items(): - files = glob.glob(os.path.join(dir, '**/*.js'), recursive=True) + files = glob.glob(os.path.join(glob.escape(dir), '**/*.js'), recursive=True) extensions.extend(list(map(lambda f: "/extensions/" + urllib.parse.quote( name) + "/" + os.path.relpath(f, dir).replace("\\", "/"), files)))