Philipp Hörist pushed to branch openpgp at gajim / gajim
Commits:
ce17e5c1 by Philipp Hörist at 2026-05-03T10:24:44+02:00
imprv: Add regex validation to password
- - - - -
3 changed files:
- gajim/common/modules/openpgp.py
- gajim/common/regex.py
- gajim/gtk/openpgp_wizard.py
Changes:
=====================================
gajim/common/modules/openpgp.py
=====================================
@@ -226,6 +226,14 @@ def __init__(self, client: Client):
timeout_add_seconds_once(random.randint(30, 60),
self.check_secret_key_backup)
+ app.settings.connect_signal(
+ "openpgp_backup_secret_key", self._on_backup_settng_changed,
self._account
+ )
+
+ def _on_backup_settng_changed(self, enabled: bool, *args: Any) -> None:
+ if enabled:
+ self.check_secret_key_backup()
+
def _load_secret_keys(self) -> None:
if row := app.storage.openpgp.get_secret_key(self._own_jid):
secret, self._secret_key_date = row
=====================================
gajim/common/regex.py
=====================================
@@ -451,3 +451,5 @@ class XMPP:
r"\U000E0100-\U000E01EF"
)
NON_SPACING_MARKS_REGEX = re.compile(f" (?=[{NON_SPACING_MARKS}])")
+
+OPENPGP_BACKUP_PASSWORD_RX = re.compile(r"([A-NP-Z1-9]{4}-){5}[A-NP-Z1-9]{4}")
=====================================
gajim/gtk/openpgp_wizard.py
=====================================
@@ -18,6 +18,7 @@
from gajim.common.modules.openpgp import format_fingerprint
from gajim.common.modules.openpgp import MultipleSecretKeysImportError
from gajim.common.modules.util import Task
+from gajim.common.regex import OPENPGP_BACKUP_PASSWORD_RX
from gajim.plugins.plugins_i18n import _
from gajim.gtk.activity_list import OpenPGPEvent
@@ -359,13 +360,12 @@ def get_visible_buttons(self) -> list[str]:
return ["other-options", "restore"]
def _on_entry_changed(self, entry: Gtk.PasswordEntry) -> None:
- ## TODO validate input against regex
- self.complete = True
+ res =
OPENPGP_BACKUP_PASSWORD_RX.fullmatch(self._password_entry.get_text())
+ self.complete = res is not None
self.update_page_complete()
def get_password(self) -> str:
- password = self._password_entry.get_text()
- return password.upper().strip()
+ return self._password_entry.get_text()
@Gtk.Template(string=get_ui_string("openpgp/choose_secret_key.ui"))
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/ce17e5c1d11cb5ef4305530f66271872710dd86d
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/ce17e5c1d11cb5ef4305530f66271872710dd86d
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]