Skip to content

Commit dd4b0b9

Browse files
committed
cmd args: allow unix filenames and filenames max length
1 parent c8a5322 commit dd4b0b9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

modules/cmd_args.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,6 @@
120120
parser.add_argument('--timeout-keep-alive', type=int, default=30, help='set timeout_keep_alive for uvicorn')
121121
parser.add_argument("--disable-all-extensions", action='store_true', help="prevent all extensions from running regardless of any other settings", default=False)
122122
parser.add_argument("--disable-extra-extensions", action='store_true', help="prevent all extensions except built-in from running regardless of any other settings", default=False)
123-
parser.add_argument("--skip-load-model-at-start", action='store_true', help="if load a model at web start, only take effect when --nowebui", )
123+
parser.add_argument("--skip-load-model-at-start", action='store_true', help="if load a model at web start, only take effect when --nowebui")
124+
parser.add_argument("--unix-filenames-sanitization", action='store_true', help="allow any symbols except '/' in filenames. May conflict with your browser and file system")
125+
parser.add_argument("--filenames-max-length", type=int, default=128, help='maximal length of filenames of saved images. If you override it, it can conflict with your file system')

modules/images.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,16 @@ def resize(im, w, h):
321321
return res
322322

323323

324-
invalid_filename_chars = '#<>:"/\\|?*\n\r\t'
324+
if not shared.cmd_opts.unix_filenames_sanitization:
325+
invalid_filename_chars = '#<>:"/\\|?*\n\r\t'
326+
else:
327+
invalid_filename_chars = '/'
325328
invalid_filename_prefix = ' '
326329
invalid_filename_postfix = ' .'
327330
re_nonletters = re.compile(r'[\s' + string.punctuation + ']+')
328331
re_pattern = re.compile(r"(.*?)(?:\[([^\[\]]+)\]|$)")
329332
re_pattern_arg = re.compile(r"(.*)<([^>]*)>$")
330-
max_filename_part_length = 128
333+
max_filename_part_length = shared.cmd_opts.filenames_max_length
331334
NOTHING_AND_SKIP_PREVIOUS_TEXT = object()
332335

333336

0 commit comments

Comments
 (0)