commit bb5d1d0ceecfb59903cccfba0a2e13f77e39e956
parent 99372f3ea2192b1a6d6d5e79eb878cc17735acec
Author: Antoine A <>
Date: Tue, 16 Apr 2024 15:26:07 +0900
Fix config escaping
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git 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)