Mercurial > prosody-hg
comparison util/jid.lua @ 10411:db2a06b9ff98
Merge 0.11->trunk
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 16 Nov 2019 16:52:31 +0100 |
| parents | a77d9b3885bb |
| children | 0b0a42542456 |
comparison
equal
deleted
inserted
replaced
| 10410:659b577f280c | 10411:db2a06b9ff98 |
|---|---|
| 43 return node.."@"..host; | 43 return node.."@"..host; |
| 44 end | 44 end |
| 45 return host; | 45 return host; |
| 46 end | 46 end |
| 47 | 47 |
| 48 local function prepped_split(jid) | 48 local function prepped_split(jid, strict) |
| 49 local node, host, resource = split(jid); | 49 local node, host, resource = split(jid); |
| 50 if host and host ~= "." then | 50 if host and host ~= "." then |
| 51 if sub(host, -1, -1) == "." then -- Strip empty root label | 51 if sub(host, -1, -1) == "." then -- Strip empty root label |
| 52 host = sub(host, 1, -2); | 52 host = sub(host, 1, -2); |
| 53 end | 53 end |
| 54 host = nameprep(host); | 54 host = nameprep(host, strict); |
| 55 if not host then return; end | 55 if not host then return; end |
| 56 if node then | 56 if node then |
| 57 node = nodeprep(node); | 57 node = nodeprep(node, strict); |
| 58 if not node then return; end | 58 if not node then return; end |
| 59 end | 59 end |
| 60 if resource then | 60 if resource then |
| 61 resource = resourceprep(resource); | 61 resource = resourceprep(resource, strict); |
| 62 if not resource then return; end | 62 if not resource then return; end |
| 63 end | 63 end |
| 64 return node, host, resource; | 64 return node, host, resource; |
| 65 end | 65 end |
| 66 end | 66 end |
| 75 return host.."/"..resource; | 75 return host.."/"..resource; |
| 76 end | 76 end |
| 77 return host; | 77 return host; |
| 78 end | 78 end |
| 79 | 79 |
| 80 local function prep(jid) | 80 local function prep(jid, strict) |
| 81 local node, host, resource = prepped_split(jid); | 81 local node, host, resource = prepped_split(jid, strict); |
| 82 return join(node, host, resource); | 82 return join(node, host, resource); |
| 83 end | 83 end |
| 84 | 84 |
| 85 local function compare(jid, acl) | 85 local function compare(jid, acl) |
| 86 -- compare jid to single acl rule | 86 -- compare jid to single acl rule |
