From 122a6b7e28a5ccd88cbac4748a70c04c9af036d6 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sat, 8 Nov 2003 08:52:57 +0000 Subject: [PATCH] Better escaping. --- src/common/common.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/common/common.cpp b/src/common/common.cpp index 193faae17..62d1498c6 100644 --- a/src/common/common.cpp +++ b/src/common/common.cpp @@ -1000,7 +1000,9 @@ string escape(const char *src) { if (*src == '\\') dst += "\\\\"; else if (*src == '"') - dst += '2'; // Yes, this IS a trick ;) + dst += "\\2"; // Yes, this IS a trick ;) + else if (*src == ' ') + dst += "\\s"; else dst += *src; src++; @@ -1018,11 +1020,13 @@ string unescape(const char *src) { if (*src == '\\') { if (*next_char == 0) // This is an error... dst += '\\'; - else if (*next_char == '2') { - dst += '"'; - src++; - } else { - dst += *next_char; + else { + if (*next_char == '2') + dst += '"'; + else if (*next_char == 's') + dst += ' '; + else + dst += *next_char; src++; } } else