From 48e5dc6763b664fb307d2894cedab0a9aaf09630 Mon Sep 17 00:00:00 2001
From: Leonidas Spyropoulos
Date: Thu, 27 Oct 2022 15:49:48 +0100
Subject: [PATCH] feat: remove empty lines from ssh_keys text area, and show
helpful message
Signed-off-by: Leonidas Spyropoulos
---
aurweb/util.py | 2 +-
po/aurweb.pot | 4 ++++
templates/partials/account_form.html | 7 +++++++
test/test_util.py | 29 +++++++++++++++++++++++++---
4 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/aurweb/util.py b/aurweb/util.py
index 0a39cd3d..7b997609 100644
--- a/aurweb/util.py
+++ b/aurweb/util.py
@@ -192,7 +192,7 @@ def parse_ssh_key(string: str) -> Tuple[str, str]:
def parse_ssh_keys(string: str) -> list[Tuple[str, str]]:
"""Parse a list of SSH public keys."""
- return [parse_ssh_key(e) for e in string.splitlines()]
+ return [parse_ssh_key(e) for e in string.strip().splitlines(True) if e.strip()]
def shell_exec(cmdline: str, cwd: str) -> Tuple[int, str, str]:
diff --git a/po/aurweb.pot b/po/aurweb.pot
index 1838fae5..ff1bde8b 100644
--- a/po/aurweb.pot
+++ b/po/aurweb.pot
@@ -1398,6 +1398,10 @@ msgid ""
"the Arch User Repository."
msgstr ""
+#: templates/partials/account_form.html
+msgid "Specify multiple SSH Keys separated by new line, empty lines are ignored."
+msgstr ""
+
#: template/account_edit_form.php
msgid "SSH Public Key"
msgstr ""
diff --git a/templates/partials/account_form.html b/templates/partials/account_form.html
index 007fb389..a433a57d 100644
--- a/templates/partials/account_form.html
+++ b/templates/partials/account_form.html
@@ -264,6 +264,13 @@
+
+
+ {{
+ "Specify multiple SSH Keys separated by new line, empty lines are ignored." | tr
+ }}
+
+