@@ -29,7 +29,7 @@ def is_safe_path(base_dir: Path, target_path: Path) -> bool:
2929 resolved_target = target_path .resolve (strict = True )
3030 # Check if the resolved target path is a subpath of the resolved base path
3131 return resolved_target .is_relative_to (resolved_base )
32- except (FileNotFoundError , RuntimeError ):
32+ except (FileNotFoundError , RuntimeError , OSError ):
3333 # strict=True raises FileNotFoundError if path doesn't exist
3434 # is_relative_to can raise RuntimeError on Windows with different drives
3535 # In these cases, we can check the unresolved path as a fallback
@@ -154,9 +154,9 @@ def list_directory_recursive(
154154
155155 current_path = Path (root ).relative_to (base_dir )
156156 for name in sorted (dirs ):
157- contents .append (f"{ current_path / name } /" )
157+ contents .append (f"{ ( current_path / name ). as_posix () } /" )
158158 for name in sorted (files ):
159- contents .append (str (current_path / name ))
159+ contents .append (str (( current_path / name ). as_posix () ))
160160 return contents
161161
162162
@@ -169,5 +169,8 @@ def list_directory_non_recursive(
169169 if not show_hidden and entry .name .startswith ("." ):
170170 continue
171171 relative_path = entry .relative_to (base_dir )
172- contents .append (f"{ relative_path } /" if entry .is_dir () else str (relative_path ))
172+ if entry .is_dir ():
173+ contents .append (f"{ relative_path .as_posix ()} /" )
174+ else :
175+ contents .append (str (relative_path .as_posix ()))
173176 return contents
0 commit comments