From 0e485625ffd13f34b989943d71f1bbbff5b31e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emirhan=20Karag=C3=BCl?= Date: Thu, 28 Apr 2022 00:25:25 +0200 Subject: [PATCH] Update single layer stripping --- share/tools/web_config/webconfig.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index fab77284e..7289e5879 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -139,6 +139,14 @@ def escape_fish_cmd(text): escaped = text.replace("\\", "\\\\").replace("'", "\\'") return "'" + escaped + "'" +def strip_one_layer(text, char): + # Strip the text from one layer of a given character + if text[-1]==char: + text = text[:-1] + if text[0]==char: + text = text[1:] + return text + named_colors = { "black": "000000", @@ -1329,8 +1337,8 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): # Remove one layer of single-quotes because escape_fish_cmd adds them back. "abbr --add %s %s" % ( - escape_fish_cmd(abbreviation["word"].strip("'")), - escape_fish_cmd(abbreviation["phrase"].strip("'")), + escape_fish_cmd(strip_one_layer(abbreviation["word"], "'")), + escape_fish_cmd(strip_one_layer(abbreviation["phrase"], "'")), ) ) if err: