aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2009-09-18 02:11:16 +0500
committerWaqas Hussain <waqas20@gmail.com>2009-09-18 02:11:16 +0500
commitbe1f06afddb60e82f89f268036a01178d123a04e (patch)
tree63e543c042bb28686da961e92243f431b05bdabf
parent7fc7394567964bd3b9791a2f01c22f0cf295f536 (diff)
downloadprosody-be1f06afddb60e82f89f268036a01178d123a04e.tar.gz
prosody-be1f06afddb60e82f89f268036a01178d123a04e.zip
ejabberd2prosody: Fixed escape code processing when parsing strings.
-rw-r--r--tools/erlparse.lua16
1 files changed, 13 insertions, 3 deletions
diff --git a/tools/erlparse.lua b/tools/erlparse.lua
index f2d410a3..bfec3b4d 100644
--- a/tools/erlparse.lua
+++ b/tools/erlparse.lua
@@ -45,16 +45,26 @@ local function isSpace(ch)
return ch <= _space;
end
+local escapes = {["\\b"]="\b", ["\\d"]="\d", ["\\e"]="\e", ["\\f"]="\f", ["\\n"]="\n", ["\\r"]="\r", ["\\s"]="\s", ["\\t"]="\t", ["\\v"]="\v", ["\\\""]="\"", ["\\'"]="'", ["\\\\"]="\\"};
local function readString()
read("\""); -- skip quote
local slash = nil;
local str = "";
while true do
local ch = read();
- if ch == "\"" and not slash then break; end
- str = str..ch;
+ if slash then
+ slash = slash..ch;
+ if not escapes[slash] then error("Unknown escape sequence: "..slash); end
+ str = str..escapes[slash];
+ slash = nil;
+ elseif ch == "\"" then
+ break;
+ elseif ch == "\\" then
+ slash = ch;
+ else
+ str = str..ch;
+ end
end
- str = str:gsub("\\.", {["\\b"]="\b", ["\\d"]="\d", ["\\e"]="\e", ["\\f"]="\f", ["\\n"]="\n", ["\\r"]="\r", ["\\s"]="\s", ["\\t"]="\t", ["\\v"]="\v", ["\\\""]="\"", ["\\'"]="'", ["\\\\"]="\\"});
return str;
end
local function readAtom1()