From 604b6c00f8cc4d70074418c41f7a889253067b62 Mon Sep 17 00:00:00 2001 From: antoniogfs <91247199+antoniogfs@users.noreply.github.com> Date: Mon, 11 May 2026 20:41:55 +0200 Subject: [PATCH 1/3] Fix newline handling in JSON data for keyring --- proton/keyring_linux/core/keyring_linux.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proton/keyring_linux/core/keyring_linux.py b/proton/keyring_linux/core/keyring_linux.py index b162010..ace1df9 100644 --- a/proton/keyring_linux/core/keyring_linux.py +++ b/proton/keyring_linux/core/keyring_linux.py @@ -82,7 +82,8 @@ def _del_item(self, key): raise KeyringError(excp) from excp def _set_item(self, key, value): - json_data = json.dumps(value) + value = json.dumps(value).replace("\n", "\\n") + json_data = value try: self.__keyring_backend.set_password( self.KEYRING_SERVICE, From c8f799eb4c39ea5dfc3b362fb8e5bbe0c49fc067 Mon Sep 17 00:00:00 2001 From: antoniogfs <91247199+antoniogfs@users.noreply.github.com> Date: Thu, 14 May 2026 18:26:36 +0200 Subject: [PATCH 2/3] Change keyring data storage to base64 encoding Update storage format to base64 encode JSON data for keyring. --- proton/keyring_linux/core/keyring_linux.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/proton/keyring_linux/core/keyring_linux.py b/proton/keyring_linux/core/keyring_linux.py index ace1df9..1ddef4d 100644 --- a/proton/keyring_linux/core/keyring_linux.py +++ b/proton/keyring_linux/core/keyring_linux.py @@ -24,6 +24,7 @@ along with ProtonVPN. If not, see . """ import json +import base64 import logging import keyring @@ -65,7 +66,7 @@ def _get_item(self, key): raise KeyError(key) try: - return json.loads(stored_data) + return json.loads(base64.b64decode(stored_data).decode("utf-8")) except json.JSONDecodeError as excp: # Delete data (it's invalid anyway) self._del_item(key) @@ -82,8 +83,8 @@ def _del_item(self, key): raise KeyringError(excp) from excp def _set_item(self, key, value): - value = json.dumps(value).replace("\n", "\\n") - json_data = value + value = json.dumps(value) + json_data = base64.b64encode(value.encode("utf-8")).decode("utf-8") try: self.__keyring_backend.set_password( self.KEYRING_SERVICE, From 6e10b1537e099a63db6bfca515dd1939258bb1ed Mon Sep 17 00:00:00 2001 From: antoniogfs <91247199+antoniogfs@users.noreply.github.com> Date: Thu, 14 May 2026 19:01:45 +0200 Subject: [PATCH 3/3] Update data retrieval to decode base64 Decode stored data from base64 before loading JSON. --- proton/keyring_linux/secretservice/secretservice_backend.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proton/keyring_linux/secretservice/secretservice_backend.py b/proton/keyring_linux/secretservice/secretservice_backend.py index 3a9bac1..2f5fa98 100644 --- a/proton/keyring_linux/secretservice/secretservice_backend.py +++ b/proton/keyring_linux/secretservice/secretservice_backend.py @@ -19,6 +19,7 @@ along with ProtonVPN. If not, see . """ import json +import base64 import logging import keyring @@ -70,7 +71,7 @@ def _get_item(self, key): raise KeyError(key) try: - return json.loads(stored_data) + return json.loads(base64.b64decode(stored_data).decode("utf-8")) except json.JSONDecodeError: # gnome-keyring has a bug when processing new lines. # Anytime we store the data to the keyring, we store all newlines in