From bfc2fc4c9521427dc3b58a5bd38f53814cc0d22a Mon Sep 17 00:00:00 2001 From: usmannasir Date: Sat, 19 Oct 2024 17:08:17 +0500 Subject: [PATCH] bug fix: do not allow prohibited characters in oc backups --- backup/backupManager.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/backup/backupManager.py b/backup/backupManager.py index 7635bddfa..37b52ec83 100755 --- a/backup/backupManager.py +++ b/backup/backupManager.py @@ -1942,6 +1942,16 @@ class BackupManager: try: + userName = user.userName.lower() + + not_allowed_characters = [ + ' ', '/', '\\', '@', '!', '#', '$', '%', '^', '&', '*', '(', ')', '+', '=', + '{', '}', '[', ']', ':', ';', '"', "'", '<', '>', ',', '?', '|', '`', '~' + ] + + for items in not_allowed_characters: + userName = userName.replace(items, '') + backup_plan = OneClickBackups( owner=user, planName=plan_name, @@ -1949,7 +1959,7 @@ class BackupManager: price=price, customer=customer, subscription=subscription, - sftpUser=f'{user.userName}{str(randint(1000, 9999))}', + sftpUser=f'{userName}{str(randint(1000, 9999))}', ) backup_plan.save()