diff --git a/ui/opensnitch/dialogs/ruleseditor/dialog.py b/ui/opensnitch/dialogs/ruleseditor/dialog.py index dc87090a95..160d366a27 100644 --- a/ui/opensnitch/dialogs/ruleseditor/dialog.py +++ b/ui/opensnitch/dialogs/ruleseditor/dialog.py @@ -894,5 +894,13 @@ def save_rule(self): if self.ruleNameEdit.text() == "": self.rule.name = slugify("%s %s %s" % (self.rule.action, self.rule.operator.type, self.rule.operator.data)) + elif self._old_rule_name is not None: + # If the rule name was auto-generated (starts with an action prefix), + # and the action has changed, update the prefix to match the new action. + for old_action in (Config.ACTION_ALLOW, Config.ACTION_DENY, Config.ACTION_REJECT): + if self._old_rule_name.startswith(old_action + "-") and old_action != self.rule.action: + self.rule.name = self.rule.action + self._old_rule_name[len(old_action):] + self.ruleNameEdit.setText(self.rule.name) + break return True, ""