From d4e0e89158a4dbb8743e550507512b1f9592d859 Mon Sep 17 00:00:00 2001 From: chrisdebian Date: Mon, 18 May 2026 16:16:16 +0100 Subject: [PATCH 1/2] fix: disable configparser interpolation to support passwords with % MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit configparser.ConfigParser() uses BasicInterpolation by default, which treats % in values as variable references (e.g. %m, %s). A password containing % raises: InterpolationSyntaxError: invalid interpolation syntax in '...' Pass interpolation=None to disable this behaviour so credentials are stored and retrieved literally regardless of content. Fixes #67 (MapSyncer) — root cause is in this config reader. Co-Authored-By: Claude Sonnet 4.6 (cherry picked from commit 739bfd2b8d4e60ee5f9b634bbaf7dfd307197e8c) --- mapilio_kit/components/utilities/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapilio_kit/components/utilities/config.py b/mapilio_kit/components/utilities/config.py index 3640fb6..a410c7f 100644 --- a/mapilio_kit/components/utilities/config.py +++ b/mapilio_kit/components/utilities/config.py @@ -36,7 +36,7 @@ def load_config(config_path: str) -> configparser.ConfigParser: if not os.path.isfile(config_path): raise RuntimeError(f"config {config_path} does not exist") - config = configparser.ConfigParser() + config = configparser.ConfigParser(interpolation=None) config.optionxform = str # type: ignore config.read(config_path) return config From 772d2806cf2758109c9b513ca11c96001180b31f Mon Sep 17 00:00:00 2001 From: Ozcan Date: Fri, 30 Oct 2026 19:20:27 +0300 Subject: [PATCH 2/2] test: cover literal credential roundtrips --- tests/test_config.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/test_config.py diff --git a/tests/test_config.py b/tests/test_config.py new file mode 100644 index 0000000..7ad2875 --- /dev/null +++ b/tests/test_config.py @@ -0,0 +1,23 @@ +"""Credential files must preserve user supplied strings literally.""" + +import pytest + +from mapilio_kit.components.utilities import config + + +@pytest.mark.parametrize("password", ["plain", "prefix%m", "prefix%s", "%(missing)s", "50%%literal"]) +def test_credentials_roundtrip_without_interpolation(tmp_path, password): + path = tmp_path / "configs" / "CLIENT_USERS" + config.create_config(str(path)) + expected = { + "SettingsEmail": "fixture@example.invalid", + "SettingsUsername": "fixture-user", + "SettingsUserPassword": password, + "SettingsUserKey": "123", + "user_upload_token": "synthetic-token", + } + + config.update_config(str(path), "fixture-user", expected) + + actual = config.load_user(config.load_config(str(path)), "fixture-user") + assert actual == expected