util.jid: Strip trailing '.' when normalizing hostnames
authorMatthew Wild <mwild1@gmail.com>
Mon, 16 Dec 2013 02:03:35 +0000 (02:03 +0000)
committerMatthew Wild <mwild1@gmail.com>
Mon, 16 Dec 2013 02:03:35 +0000 (02:03 +0000)
util/jid.lua

index 4c4371d805361006d87b842f3ebd55f646709eca..8e0a784cc49abb3a0a25531043f993e23ed0cf13 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