File tree Expand file tree Collapse file tree
react_with_database_memory
llamaindex/websearch_agent
vanilla_python/openai_responses_agent Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import time
66import uuid
77from contextlib import asynccontextmanager
8+ import os
89from os import getenv
910from pathlib import Path
1011
@@ -385,7 +386,9 @@ async def serve_image(filename: str):
385386 """Serve images from the project-level images directory."""
386387 base = _IMAGES_DIR .resolve ()
387388 file_path = (base / filename ).resolve ()
388- if not file_path .is_relative_to (base ):
389+ base_str = str (base )
390+ file_path_str = str (file_path )
391+ if not (file_path_str == base_str or file_path_str .startswith (base_str + os .path .sep )):
389392 raise HTTPException (status_code = 404 , detail = "Image not found" )
390393 if not file_path .is_file ():
391394 raise HTTPException (status_code = 404 , detail = "Image not found" )
Original file line number Diff line number Diff line change 33import time
44import uuid
55from contextlib import asynccontextmanager
6+ import os
67from os import getenv
78from pathlib import Path
89
@@ -409,7 +410,9 @@ async def serve_image(filename: str):
409410 """Serve images from the project-level images directory."""
410411 base = _IMAGES_DIR .resolve ()
411412 file_path = (base / filename ).resolve ()
412- if not file_path .is_relative_to (base ):
413+ base_str = str (base )
414+ file_path_str = str (file_path )
415+ if not (file_path_str == base_str or file_path_str .startswith (base_str + os .path .sep )):
413416 raise HTTPException (status_code = 404 , detail = "Image not found" )
414417 if not file_path .is_file ():
415418 raise HTTPException (status_code = 404 , detail = "Image not found" )
Original file line number Diff line number Diff line change 33import time
44import uuid
55from contextlib import asynccontextmanager
6+ import os
67from os import getenv
78from pathlib import Path
89
@@ -405,7 +406,9 @@ async def serve_image(filename: str):
405406 """Serve images from the project-level images directory."""
406407 base = _IMAGES_DIR .resolve ()
407408 file_path = (base / filename ).resolve ()
408- if not file_path .is_relative_to (base ):
409+ base_str = str (base )
410+ file_path_str = str (file_path )
411+ if not (file_path_str == base_str or file_path_str .startswith (base_str + os .path .sep )):
409412 raise HTTPException (status_code = 404 , detail = "Image not found" )
410413 if not file_path .is_file ():
411414 raise HTTPException (status_code = 404 , detail = "Image not found" )
Original file line number Diff line number Diff line change 1212from langgraph .checkpoint .postgres import PostgresSaver
1313from langgraph .checkpoint .postgres .aio import AsyncPostgresSaver
1414from pydantic import BaseModel , Field
15+ import os
1516from os import getenv
1617
1718from react_with_database_memory .agent import get_graph_closure
@@ -486,7 +487,9 @@ async def serve_image(filename: str):
486487 """Serve images from the project-level images directory."""
487488 base = _IMAGES_DIR .resolve ()
488489 file_path = (base / filename ).resolve ()
489- if not file_path .is_relative_to (base ):
490+ base_str = str (base )
491+ file_path_str = str (file_path )
492+ if not (file_path_str == base_str or file_path_str .startswith (base_str + os .path .sep )):
490493 raise HTTPException (status_code = 404 , detail = "Image not found" )
491494 if not file_path .is_file ():
492495 raise HTTPException (status_code = 404 , detail = "Image not found" )
Original file line number Diff line number Diff line change 33import time
44import uuid
55from contextlib import asynccontextmanager
6+ import os
67from os import getenv
78from pathlib import Path
89
@@ -471,7 +472,9 @@ async def serve_image(filename: str):
471472 """Serve images from the project-level images directory."""
472473 base = _IMAGES_DIR .resolve ()
473474 file_path = (base / filename ).resolve ()
474- if not file_path .is_relative_to (base ):
475+ base_str = str (base )
476+ file_path_str = str (file_path )
477+ if not (file_path_str == base_str or file_path_str .startswith (base_str + os .path .sep )):
475478 raise HTTPException (status_code = 404 , detail = "Image not found" )
476479 if not file_path .is_file ():
477480 raise HTTPException (status_code = 404 , detail = "Image not found" )
Original file line number Diff line number Diff line change 44import time
55import uuid
66from contextlib import asynccontextmanager
7+ import os
78from os import getenv
89from pathlib import Path
910
@@ -406,7 +407,9 @@ async def serve_image(filename: str):
406407 """Serve images from the project-level images directory."""
407408 base = _IMAGES_DIR .resolve ()
408409 file_path = (base / filename ).resolve ()
409- if not file_path .is_relative_to (base ):
410+ base_str = str (base )
411+ file_path_str = str (file_path )
412+ if not (file_path_str == base_str or file_path_str .startswith (base_str + os .path .sep )):
410413 raise HTTPException (status_code = 404 , detail = "Image not found" )
411414 if not file_path .is_file ():
412415 raise HTTPException (status_code = 404 , detail = "Image not found" )
You can’t perform that action at this time.
0 commit comments