handle invalid filenames in styles

This commit is contained in:
Vladimir Mandic
2023-09-10 19:57:28 -04:00
parent a9b3b0e806
commit cb51e55c28
+3 -1
View File
@@ -98,7 +98,9 @@ class StyleDatabase:
"extra": "",
"preview": "",
}
fn = os.path.join(path, name + ".json")
keepcharacters = (' ','.','_')
fn = "".join(c for c in name if c.isalnum() or c in keepcharacters).rstrip()
fn = os.path.join(path, fn + ".json")
try:
with open(fn, 'w', encoding='utf-8') as f:
json.dump(style, f, indent=2)