From 22a6ba9ccaaa10d6a83faba7c02ecdbc0d5432c4 Mon Sep 17 00:00:00 2001 From: master3395 Date: Mon, 26 Jan 2026 03:28:21 +0100 Subject: [PATCH] fix(plugins): Fix removeFromSettings to properly track INSTALLED_APPS section - Track INSTALLED_APPS section state while iterating - Only remove plugin if found within INSTALLED_APPS section - Prevents removing plugin references from comments or other sections --- pluginInstaller/pluginInstaller.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pluginInstaller/pluginInstaller.py b/pluginInstaller/pluginInstaller.py index 6425fb053..30288ccf5 100644 --- a/pluginInstaller/pluginInstaller.py +++ b/pluginInstaller/pluginInstaller.py @@ -387,11 +387,18 @@ class pluginInstaller: def removeFromSettings(pluginName): data = open("/usr/local/CyberCP/CyberCP/settings.py", 'r', encoding='utf-8').readlines() writeToFile = open("/usr/local/CyberCP/CyberCP/settings.py", 'w', encoding='utf-8') - - for items in data: + + in_installed_apps = False + for i, items in enumerate(data): + # Track if we're in INSTALLED_APPS section + if 'INSTALLED_APPS' in items and '=' in items: + in_installed_apps = True + elif in_installed_apps and items.strip().startswith(']'): + in_installed_apps = False + # More precise matching: look for plugin name in quotes (e.g., 'pluginName' or "pluginName") - # This prevents partial matches (e.g., 'pluginName2' matching 'pluginName') - if (f"'{pluginName}'" in items or f'"{pluginName}"' in items) and 'INSTALLED_APPS' in ''.join(data[max(0, data.index(items)-5):data.index(items)+5]): + # Only match if we're in INSTALLED_APPS section to prevent false positives + if in_installed_apps and (f"'{pluginName}'" in items or f'"{pluginName}"' in items): continue else: writeToFile.writelines(items)