@@ -45,6 +45,30 @@ def api_only():
4545 )
4646
4747
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 check should be removed when it's no longer applicable.
59+ """
60+ from modules .paths_internal import script_path
61+ from gradio .utils import abspath
62+ if any (part .startswith ("." ) for part in abspath (script_path ).parts ):
63+ print (f'''{ "!" * 25 } Warning { "!" * 25 }
64+ WebUI is installed in a directory that has a leading dot (.) in one of its parent directories.
65+ This will prevent WebUI from functioning properly.
66+ Please move the installation to a different directory.
67+ Current path: "{ script_path } "
68+ For more information see: https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/13292
69+ { "!" * 25 } Warning { "!" * 25 } ''' )
70+
71+
4872def webui ():
4973 from modules .shared_cmd_options import cmd_opts
5074
@@ -53,6 +77,8 @@ def webui():
5377
5478 from modules import shared , ui_tempdir , script_callbacks , ui , progress , ui_extra_networks
5579
80+ warning_if_invalid_install_dir ()
81+
5682 while 1 :
5783 if shared .opts .clean_temp_dir_at_start :
5884 ui_tempdir .cleanup_tmpdr ()
0 commit comments