Software /
code /
prosody
Comparison
util/jid.lua @ 5944:f3817912e8b2
util.jid: Strip trailing '.' when normalizing hostnames
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 16 Dec 2013 02:03:35 +0000 |
parent | 4407:f78c6f5fa090 |
child | 5945:51ead0aa3a02 |
comparison
equal
deleted
inserted
replaced
5943:355f8b59bf1b | 5944:f3817912e8b2 |
---|---|
6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
7 -- | 7 -- |
8 | 8 |
9 | 9 |
10 | 10 |
11 local match = string.match; | 11 local match, sub = string.match, string.sub; |
12 local nodeprep = require "util.encodings".stringprep.nodeprep; | 12 local nodeprep = require "util.encodings".stringprep.nodeprep; |
13 local nameprep = require "util.encodings".stringprep.nameprep; | 13 local nameprep = require "util.encodings".stringprep.nameprep; |
14 local resourceprep = require "util.encodings".stringprep.resourceprep; | 14 local resourceprep = require "util.encodings".stringprep.resourceprep; |
15 | 15 |
16 local escapes = { | 16 local escapes = { |
45 end | 45 end |
46 | 46 |
47 local function _prepped_split(jid) | 47 local function _prepped_split(jid) |
48 local node, host, resource = _split(jid); | 48 local node, host, resource = _split(jid); |
49 if host then | 49 if host then |
50 if sub(host, -1, -1) == "." then -- Strip empty root label | |
51 host = sub(host, 1, -2); | |
52 end | |
50 host = nameprep(host); | 53 host = nameprep(host); |
51 if not host then return; end | 54 if not host then return; end |
52 if node then | 55 if node then |
53 node = nodeprep(node); | 56 node = nodeprep(node); |
54 if not node then return; end | 57 if not node then return; end |