diff options
author | Matthew Wild <mwild1@gmail.com> | 2011-11-02 07:17:26 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2011-11-02 07:17:26 +0000 |
commit | 0d104175eae496d612391f0aafc28fd0ba20c5f9 (patch) | |
tree | bcb788812b22466058e556eb3728670991458b01 /util | |
parent | cea60b7a5d8f81f2515bd273279141d9925728f1 (diff) | |
parent | 464f525c81423ff7b8d6814fceeb0657b8cbcc29 (diff) | |
download | prosody-0d104175eae496d612391f0aafc28fd0ba20c5f9.tar.gz prosody-0d104175eae496d612391f0aafc28fd0ba20c5f9.zip |
Merge with Zash
Diffstat (limited to 'util')
-rw-r--r-- | util/jid.lua | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/util/jid.lua b/util/jid.lua index 069817c6..4c4371d8 100644 --- a/util/jid.lua +++ b/util/jid.lua @@ -13,6 +13,16 @@ local nodeprep = require "util.encodings".stringprep.nodeprep; local nameprep = require "util.encodings".stringprep.nameprep; local resourceprep = require "util.encodings".stringprep.resourceprep; +local escapes = { + [" "] = "\\20"; ['"'] = "\\22"; + ["&"] = "\\26"; ["'"] = "\\27"; + ["/"] = "\\2f"; [":"] = "\\3a"; + ["<"] = "\\3c"; [">"] = "\\3e"; + ["@"] = "\\40"; ["\\"] = "\\5c"; +}; +local unescapes = {}; +for k,v in pairs(escapes) do unescapes[v] = k; end + module "jid" local function _split(jid) @@ -91,4 +101,7 @@ function compare(jid, acl) return false end +function escape(s) return s and (s:gsub(".", escapes)); end +function unescape(s) return s and (s:gsub("\\%x%x", unescapes)); end + return _M; |