From bb5d1d0ceecfb59903cccfba0a2e13f77e39e956 Mon Sep 17 00:00:00 2001 From: Antoine A <> Date: Tue, 16 Apr 2024 15:26:07 +0900 Subject: Fix config escaping --- regional-currency/config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/regional-currency/config.py b/regional-currency/config.py index a4bdf3d..107e535 100755 --- a/regional-currency/config.py +++ b/regional-currency/config.py @@ -36,7 +36,7 @@ def load_conf() -> Dict[str, str]: if v.startswith('"') and v.endswith('"'): conf[k] = v.strip('"').replace('\\"', '"') elif v.startswith("'") and v.endswith("'"): - conf[k] = v.strip("'").replace("\\'", "'") + conf[k] = v.strip("'").replace("'\\''", "'").replace("\\'", "'") else: conf[k] = v return conf @@ -52,8 +52,8 @@ def add_conf(name: str, value: str): result_conf[name] = value content = "" for key, value in conf.items(): - escaped = value.replace("'", "\\'") - content += f"{key}='{escaped}'\n" + escaped = value.replace("'", "'\\''") + content += f"export {key}='{escaped}'\n" with open(CONFIG_FILE, "w") as f: f.write(content) @@ -472,7 +472,7 @@ if ask_yes_no( content = "" for key, value in result_conf.items(): - escaped = value.replace("'", "\\'") + escaped = value.replace("'", "'\\''") content += f"export {key}='{escaped}'\n" with os.fdopen(3, "w") as f: f.write(content) -- cgit v1.2.3