mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-06-07 21:20:49 +00:00
fix the bug that makes it impossible to send images to other tabs
This commit is contained in:
parent
39827a3998
commit
aa12dfada0
@ -2,6 +2,8 @@ import base64
|
|||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import gradio as gr
|
import gradio as gr
|
||||||
from modules.shared import script_path
|
from modules.shared import script_path
|
||||||
from modules import shared
|
from modules import shared
|
||||||
@ -35,9 +37,8 @@ def quote(text):
|
|||||||
def image_from_url_text(filedata):
|
def image_from_url_text(filedata):
|
||||||
if type(filedata) == dict and filedata["is_file"]:
|
if type(filedata) == dict and filedata["is_file"]:
|
||||||
filename = filedata["name"]
|
filename = filedata["name"]
|
||||||
tempdir = os.path.normpath(tempfile.gettempdir())
|
is_in_right_dir = any(Path(temp_dir).resolve() in Path(filename).resolve().parents for temp_dir in shared.demo.temp_dirs)
|
||||||
normfn = os.path.normpath(filename)
|
assert is_in_right_dir, 'trying to open image file outside of allowed directories'
|
||||||
assert normfn.startswith(tempdir), 'trying to open image file not in temporary directory'
|
|
||||||
|
|
||||||
return Image.open(filename)
|
return Image.open(filename)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user