From 41a3e160d714cd99a42fa34bbfa3058839c2ceb1 Mon Sep 17 00:00:00 2001 From: comfyanonymous <121283862+comfyanonymous@users.noreply.github.com> Date: Sat, 1 Aug 2026 19:15:17 -0700 Subject: [PATCH] Use the actual function to check if the path is within the dir. (#15216) --- folder_paths.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/folder_paths.py b/folder_paths.py index df53542dc..6723e52c8 100644 --- a/folder_paths.py +++ b/folder_paths.py @@ -549,11 +549,10 @@ def get_save_image_path(filename_prefix: str, output_dir: str, image_width=0, im full_output_folder = os.path.join(output_dir, subfolder) - if os.path.commonpath((output_dir, os.path.abspath(full_output_folder))) != output_dir: + if not is_within_directory(output_dir, full_output_folder): err = "**** ERROR: Saving image outside the output folder is not allowed." + \ "\n full_output_folder: " + os.path.abspath(full_output_folder) + \ - "\n output_dir: " + output_dir + \ - "\n commonpath: " + os.path.commonpath((output_dir, os.path.abspath(full_output_folder))) + "\n output_dir: " + output_dir logging.error(err) raise Exception(err)