Mercurial > prosody-hg
comparison util/jid.lua @ 3480:97831dfe7f72
util.jid: Fix parsing of JIDs with no nodepart and an @ in the resourcepart (thanks seth)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 31 Aug 2010 00:38:44 +0100 |
| parents | 29e51e1c7c3d |
| children | f78c6f5fa090 |
comparison
equal
deleted
inserted
replaced
| 3479:f68198c2f68f | 3480:97831dfe7f72 |
|---|---|
| 15 | 15 |
| 16 module "jid" | 16 module "jid" |
| 17 | 17 |
| 18 local function _split(jid) | 18 local function _split(jid) |
| 19 if not jid then return; end | 19 if not jid then return; end |
| 20 local node, nodepos = match(jid, "^([^@]+)@()"); | 20 local node, nodepos = match(jid, "^([^@/]+)@()"); |
| 21 local host, hostpos = match(jid, "^([^@/]+)()", nodepos) | 21 local host, hostpos = match(jid, "^([^@/]+)()", nodepos) |
| 22 if node and not host then return nil, nil, nil; end | 22 if node and not host then return nil, nil, nil; end |
| 23 local resource = match(jid, "^/(.+)$", hostpos); | 23 local resource = match(jid, "^/(.+)$", hostpos); |
| 24 if (not host) or ((not resource) and #jid >= hostpos) then return nil, nil, nil; end | 24 if (not host) or ((not resource) and #jid >= hostpos) then return nil, nil, nil; end |
| 25 return node, host, resource; | 25 return node, host, resource; |
