Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Physton committed Sep 26, 2023
1 parent 6d76895 commit 6e06fb0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/on_app_started.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ async def _get_csv(key: str):
@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))

Expand Down
9 changes: 8 additions & 1 deletion scripts/physton_prompt/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@

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():
Expand Down

0 comments on commit 6e06fb0

Please sign in to comment.