main
Bob Mottram 2024-07-18 10:52:33 +01:00
parent ff7f7aaa09
commit d826ded287
1 changed files with 20 additions and 16 deletions

View File

@ -46,29 +46,33 @@ def import_theme(base_dir: str, filename: str) -> bool:
' missing from imported theme')
return False
new_theme_name = None
new_theme_name1 = None
try:
with open(temp_theme_dir + '/name.txt', 'r',
encoding='utf-8') as fp_theme:
new_theme_name1 = fp_theme.read()
new_theme_name = remove_eol(new_theme_name1)
if len(new_theme_name) > 20:
print('WARN: Imported theme name is too long')
return False
if len(new_theme_name) < 2:
print('WARN: Imported theme name is too short')
return False
new_theme_name = new_theme_name.lower()
forbidden_chars = (
' ', ';', '/', '\\', '?', '!', '#', '@',
':', '%', '&', '"', '+', '<', '>', '$'
)
for char in forbidden_chars:
if char in new_theme_name:
print('WARN: theme name contains forbidden character')
return False
except OSError:
print('EX: import_theme unable to read ' +
temp_theme_dir + '/name.txt')
if new_theme_name1:
new_theme_name = remove_eol(new_theme_name1)
if len(new_theme_name) > 20:
print('WARN: Imported theme name is too long')
return False
if len(new_theme_name) < 2:
print('WARN: Imported theme name is too short')
return False
new_theme_name = new_theme_name.lower()
forbidden_chars = (
' ', ';', '/', '\\', '?', '!', '#', '@',
':', '%', '&', '"', '+', '<', '>', '$'
)
for char in forbidden_chars:
if char in new_theme_name:
print('WARN: theme name contains forbidden character')
return False
if not new_theme_name:
return False