Merge 0.9->0.10
[prosody.git] / util / jid.lua
index 0d9a864fa3b1d8a4faa5e747a96c30a1c47e20a9..08e633359e6afafeeb8d8144d1df8c991ed265a2 100644 (file)
@@ -8,7 +8,7 @@
 
 
 
-local match = string.match;
+local match, sub = string.match, string.sub;
 local nodeprep = require "util.encodings".stringprep.nodeprep;
 local nameprep = require "util.encodings".stringprep.nameprep;
 local resourceprep = require "util.encodings".stringprep.resourceprep;
@@ -47,6 +47,9 @@ end
 local function _prepped_split(jid)
        local node, host, resource = _split(jid);
        if host then
+               if sub(host, -1, -1) == "." then -- Strip empty root label
+                       host = sub(host, 1, -2);
+               end
                host = nameprep(host);
                if not host then return; end
                if node then