Escape paths when passing them to globs

Try to prevent JS search from breaking on pathnames with square
brackets.
This commit is contained in:
Sean Lynch 2023-09-19 08:18:29 -04:00
parent db63aa7e53
commit 8321592408
1 changed files with 2 additions and 2 deletions

View File

@ -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)))