@@ -45,6 +45,42 @@ def api_only():
45
45
)
46
46
47
47
48
+ def warning_if_invalid_install_dir ():
49
+ """
50
+ Shows a warning if the webui is installed under a path that contains a leading dot in any of its parent directories.
51
+
52
+ Gradio '/file=' route will block access to files that have a leading dot in the path segments.
53
+ We use this route to serve files such as JavaScript and CSS to the webpage,
54
+ if those files are blocked, the webpage will not function properly.
55
+ See https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/13292
56
+
57
+ This is a security feature was added to Gradio 3.32.0 and is removed in later versions,
58
+ this function replicates Gradio file access blocking logic.
59
+
60
+ This check should be removed when it's no longer applicable.
61
+ """
62
+ from pathlib import Path
63
+
64
+ def abspath (path ):
65
+ """modified from Gradio 3.41.2 gradio.utils.abspath()"""
66
+ if path .is_absolute ():
67
+ return path
68
+ is_symlink = path .is_symlink () or any (parent .is_symlink () for parent in path .parents )
69
+ if is_symlink or path == path .resolve ():
70
+ return Path .cwd () / path
71
+ else :
72
+ return path .resolve ()
73
+ webui_root = Path (__file__ ).parent
74
+ if any (part .startswith ("." ) for part in abspath (webui_root ).parts ):
75
+ print (f'''{ "!" * 25 } Warning { "!" * 25 }
76
+ WebUI is installed in a directory that has a leading dot (.) in one of its parent directories.
77
+ This will prevent WebUI from functioning properly.
78
+ Please move the installation to a different directory.
79
+ Current path: "{ webui_root } "
80
+ For more information see: https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/13292
81
+ { "!" * 25 } Warning { "!" * 25 } ''' )
82
+
83
+
48
84
def webui ():
49
85
from modules .shared_cmd_options import cmd_opts
50
86
@@ -53,6 +89,8 @@ def webui():
53
89
54
90
from modules import shared , ui_tempdir , script_callbacks , ui , progress , ui_extra_networks
55
91
92
+ warning_if_invalid_install_dir ()
93
+
56
94
while 1 :
57
95
if shared .opts .clean_temp_dir_at_start :
58
96
ui_tempdir .cleanup_tmpdr ()
0 commit comments