summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorNicolai Haehnle <nhaehnle@gmail.com>2007-03-26 22:41:12 +0200
committerNicolai Haehnle <nhaehnle@gmail.com>2007-03-26 22:41:46 +0200
commit9544ed6a77ed6e5482983d4fea911e4c6c8f1d14 (patch)
tree54ebf135ab54485048edd63894078a396013fd34 /framework
parented98ddebb21483c40325aaa4d1caecf3860a9906 (diff)
Fix encode/decode.
I knew I shouldn't have done this. Shame on me.
Diffstat (limited to 'framework')
-rw-r--r--framework/core.py19
1 files changed, 2 insertions, 17 deletions
diff --git a/framework/core.py b/framework/core.py
index a83a92e49..16875c2b9 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -70,25 +70,10 @@ def checkDir(dirname, failifexists):
# Encode a string
def encode(text):
- r = text.__repr__()
- if r[0] == '"':
- # String surrounded by " returned, need to escape '
- r = r[1:-1].replace("'", "\\'")
- else:
- # String surrounded by ' returned, need to escape "
- r = r[1:-1].replace('"', '\\"')
- return r
+ return text.encode("string_escape")
def decode(text):
- # Unescape then reescape ", ' and \ to make sure no unescaped
- # instances remain (that could break out of eval())
- text = text.replace("\\\\", "\\")
- text = text.replace("\\'", "'")
- text = text.replace('\\"', '"')
- text = text.replace("\\", "\\\\")
- text = text.replace("'", "\\'")
- text = text.replace('"', '\\"')
- return eval('"' + text + '"')
+ return text.decode("string_escape")
testBinDir = os.path.dirname(__file__) + '/../bin/'