提交 aa12dfad 编写于 作者: A AUTOMATIC

fix the bug that makes it impossible to send images to other tabs

上级 39827a39
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册