Skip to content

Commit 0737b7e

Browse files
fix(userdata): catch invalid workflow filenames (Comfy-Org#9434) (Comfy-Org#9445)
1 parent 0963493 commit 0737b7e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

app/user_manager.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,17 @@ async def post_userdata(request):
363363
if not overwrite and os.path.exists(path):
364364
return web.Response(status=409, text="File already exists")
365365

366-
body = await request.read()
366+
try:
367+
body = await request.read()
367368

368-
with open(path, "wb") as f:
369-
f.write(body)
369+
with open(path, "wb") as f:
370+
f.write(body)
371+
except OSError as e:
372+
logging.warning(f"Error saving file '{path}': {e}")
373+
return web.Response(
374+
status=400,
375+
reason="Invalid filename. Please avoid special characters like :\\/*?\"<>|"
376+
)
370377

371378
user_path = self.get_request_user_filepath(request, None)
372379
if full_info:

0 commit comments

Comments
 (0)