This commit is contained in:
Physton
2023-09-27 00:45:38 +08:00
parent 6d76895a5c
commit 6e06fb051a
2 changed files with 9 additions and 2 deletions

View File

@@ -340,7 +340,7 @@ def on_app_started(_: gr.Blocks, app: FastAPI):
@app.get("/physton_prompt/styles")
async def _styles(file: str):
file_path = get_style_full_path(file)
if not os.path.exists(file_path):
if not file_path or not os.path.exists(file_path):
return Response(status_code=404)
return FileResponse(file_path, filename=os.path.basename(file_path))

View File

@@ -9,7 +9,14 @@ styles_path = os.path.normpath(styles_path)
def get_style_full_path(file):
global styles_path
return os.path.join(styles_path, file)
path = os.path.join(styles_path, file)
path = os.path.abspath(path)
path = os.path.normpath(path)
if not os.path.exists(path):
return None
if styles_path not in path:
return None
return path
def get_extension_css_list():