]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Introduce is_valid_filename()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 22 Oct 2023 13:22:48 +0000 (15:22 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 23 Oct 2023 08:08:54 +0000 (10:08 +0200)
mkosi/config.py

index 3e7428c54bc48f34cfda98b0ca16ac88ab5d8705..58efdc5f2cc936883a80ed6bfa3d4a8f4c1a8d82 100644 (file)
@@ -437,11 +437,16 @@ def config_make_path_parser(*,
     return config_parse_path
 
 
+def is_valid_filename(s: str) -> bool:
+    s = s.strip()
+    return not (s == "." or s == ".." or "/" in s)
+
+
 def config_parse_output(value: Optional[str], old: Optional[str]) -> Optional[str]:
     if not value:
         return None
 
-    if value == "." or value == ".." or "/" in value:
+    if not is_valid_filename(value):
         die(f"{value!r} is not a valid filename.",
             hint="Output= or --output= requires a filename with no path components. "
                  "Use OutputDirectory= or --output-dir= to configure the output directory.")