aboutsummaryrefslogtreecommitdiffstats
path: root/modules/generation_parameters_copypaste.py
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2022-11-27 20:04:42 +0000
committerAUTOMATIC <16777216c@gmail.com>2022-11-27 20:04:42 +0000
commitaa12dfada05a1f5bef558f24f3a318a1c293a01f (patch)
tree494d84a3494bdcbd8186c36c76419ff25dc706c0 /modules/generation_parameters_copypaste.py
parent39827a3998afa3ea612e7cc9a475085765d4d509 (diff)
downloadstable-diffusion-webui-gfx803-aa12dfada05a1f5bef558f24f3a318a1c293a01f.tar.gz
stable-diffusion-webui-gfx803-aa12dfada05a1f5bef558f24f3a318a1c293a01f.tar.bz2
stable-diffusion-webui-gfx803-aa12dfada05a1f5bef558f24f3a318a1c293a01f.zip
fix the bug that makes it impossible to send images to other tabs
Diffstat (limited to 'modules/generation_parameters_copypaste.py')
-rw-r--r--modules/generation_parameters_copypaste.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/generation_parameters_copypaste.py b/modules/generation_parameters_copypaste.py
index 0973c695..01980dca 100644
--- a/modules/generation_parameters_copypaste.py
+++ b/modules/generation_parameters_copypaste.py
@@ -2,6 +2,8 @@ import base64
import io
import os
import re
+from pathlib import Path
+
import gradio as gr
from modules.shared import script_path
from modules import shared
@@ -35,9 +37,8 @@ def quote(text):
def image_from_url_text(filedata):
if type(filedata) == dict and filedata["is_file"]:
filename = filedata["name"]
- tempdir = os.path.normpath(tempfile.gettempdir())
- normfn = os.path.normpath(filename)
- assert normfn.startswith(tempdir), 'trying to open image file not in temporary directory'
+ is_in_right_dir = any(Path(temp_dir).resolve() in Path(filename).resolve().parents for temp_dir in shared.demo.temp_dirs)
+ assert is_in_right_dir, 'trying to open image file outside of allowed directories'
return Image.open(filename)