Software /
code /
prosody
Annotate
util/jid.lua @ 12642:9061f9621330
Switch to a new role-based authorization framework, removing is_admin()
We began moving away from simple "is this user an admin?" permission checks
before 0.12, with the introduction of mod_authz_internal and the ability to
dynamically change the roles of individual users.
The approach in 0.12 still had various limitations however, and apart from
the introduction of roles other than "admin" and the ability to pull that info
from storage, not much actually changed.
This new framework shakes things up a lot, though aims to maintain the same
functionality and behaviour on the surface for a default Prosody
configuration. That is, if you don't take advantage of any of the new
features, you shouldn't notice any change.
The biggest change visible to developers is that usermanager.is_admin() (and
the auth provider is_admin() method) have been removed. Gone. Completely.
Permission checks should now be performed using a new module API method:
module:may(action_name, context)
This method accepts an action name, followed by either a JID (string) or
(preferably) a table containing 'origin'/'session' and 'stanza' fields (e.g.
the standard object passed to most events). It will return true if the action
should be permitted, or false/nil otherwise.
Modules should no longer perform permission checks based on the role name.
E.g. a lot of code previously checked if the user's role was prosody:admin
before permitting some action. Since many roles might now exist with similar
permissions, and the permissions of prosody:admin may be redefined
dynamically, it is no longer suitable to use this method for permission
checks. Use module:may().
If you start an action name with ':' (recommended) then the current module's
name will automatically be used as a prefix.
To define a new permission, use the new module API:
module:default_permission(role_name, action_name)
module:default_permissions(role_name, { action_name[, action_name...] })
This grants the specified role permission to execute the named action(s) by
default. This may be overridden via other mechanisms external to your module.
The built-in roles that developers should use are:
- prosody:user (normal user)
- prosody:admin (host admin)
- prosody:operator (global admin)
The new prosody:operator role is intended for server-wide actions (such as
shutting down Prosody).
Finally, all usage of is_admin() in modules has been fixed by this commit.
Some of these changes were trickier than others, but no change is expected to
break existing deployments.
EXCEPT: mod_auth_ldap no longer supports the ldap_admin_filter option. It's
very possible nobody is using this, but if someone is then we can later update
it to pull roles from LDAP somehow.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 15 Jun 2022 12:15:01 +0100 |
parent | 12605:053417068957 |
child | 12768:6e3aa3995eab |
rev | line source |
---|---|
1523
841d61be198f
Remove version number from copyright headers
Matthew Wild <mwild1@gmail.com>
parents:
1171
diff
changeset
|
1 -- Prosody IM |
2923
b7049746bd29
Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents:
2245
diff
changeset
|
2 -- Copyright (C) 2008-2010 Matthew Wild |
b7049746bd29
Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents:
2245
diff
changeset
|
3 -- Copyright (C) 2008-2010 Waqas Hussain |
5776
bd0ff8ae98a8
Remove all trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
4407
diff
changeset
|
4 -- |
758 | 5 -- This project is MIT/X11 licensed. Please see the |
6 -- COPYING file in the source package for more information. | |
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
384
diff
changeset
|
7 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
384
diff
changeset
|
8 |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
384
diff
changeset
|
9 |
0 | 10 |
7321
a7199fc8a50e
util.jid: Import select() into local (fixes traceback, tests on Lua 5.2)
Kim Alvefur <zash@zash.se>
parents:
7296
diff
changeset
|
11 local select = select; |
5944
f3817912e8b2
util.jid: Strip trailing '.' when normalizing hostnames
Matthew Wild <mwild1@gmail.com>
parents:
4407
diff
changeset
|
12 local match, sub = string.match, string.sub; |
717
ab428c579cbc
util/jid: string prepping functions added: prepped_split and prep
Waqas Hussain <waqas20@gmail.com>
parents:
615
diff
changeset
|
13 local nodeprep = require "util.encodings".stringprep.nodeprep; |
ab428c579cbc
util/jid: string prepping functions added: prepped_split and prep
Waqas Hussain <waqas20@gmail.com>
parents:
615
diff
changeset
|
14 local nameprep = require "util.encodings".stringprep.nameprep; |
ab428c579cbc
util/jid: string prepping functions added: prepped_split and prep
Waqas Hussain <waqas20@gmail.com>
parents:
615
diff
changeset
|
15 local resourceprep = require "util.encodings".stringprep.resourceprep; |
367
cc26368294a3
Remove some declarations I added while debugging
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
16 |
4407
f78c6f5fa090
util.jid: Added escape() and unescape().
Waqas Hussain <waqas20@gmail.com>
parents:
3480
diff
changeset
|
17 local escapes = { |
f78c6f5fa090
util.jid: Added escape() and unescape().
Waqas Hussain <waqas20@gmail.com>
parents:
3480
diff
changeset
|
18 [" "] = "\\20"; ['"'] = "\\22"; |
f78c6f5fa090
util.jid: Added escape() and unescape().
Waqas Hussain <waqas20@gmail.com>
parents:
3480
diff
changeset
|
19 ["&"] = "\\26"; ["'"] = "\\27"; |
f78c6f5fa090
util.jid: Added escape() and unescape().
Waqas Hussain <waqas20@gmail.com>
parents:
3480
diff
changeset
|
20 ["/"] = "\\2f"; [":"] = "\\3a"; |
f78c6f5fa090
util.jid: Added escape() and unescape().
Waqas Hussain <waqas20@gmail.com>
parents:
3480
diff
changeset
|
21 ["<"] = "\\3c"; [">"] = "\\3e"; |
f78c6f5fa090
util.jid: Added escape() and unescape().
Waqas Hussain <waqas20@gmail.com>
parents:
3480
diff
changeset
|
22 ["@"] = "\\40"; ["\\"] = "\\5c"; |
f78c6f5fa090
util.jid: Added escape() and unescape().
Waqas Hussain <waqas20@gmail.com>
parents:
3480
diff
changeset
|
23 }; |
f78c6f5fa090
util.jid: Added escape() and unescape().
Waqas Hussain <waqas20@gmail.com>
parents:
3480
diff
changeset
|
24 local unescapes = {}; |
11056
0b0a42542456
util.jid: Fix special escaping of '\' per XEP-0106
Kim Alvefur <zash@zash.se>
parents:
10358
diff
changeset
|
25 local backslash_escapes = {}; |
0b0a42542456
util.jid: Fix special escaping of '\' per XEP-0106
Kim Alvefur <zash@zash.se>
parents:
10358
diff
changeset
|
26 for k,v in pairs(escapes) do |
0b0a42542456
util.jid: Fix special escaping of '\' per XEP-0106
Kim Alvefur <zash@zash.se>
parents:
10358
diff
changeset
|
27 unescapes[v] = k; |
0b0a42542456
util.jid: Fix special escaping of '\' per XEP-0106
Kim Alvefur <zash@zash.se>
parents:
10358
diff
changeset
|
28 backslash_escapes[v] = v:gsub("\\", escapes) |
0b0a42542456
util.jid: Fix special escaping of '\' per XEP-0106
Kim Alvefur <zash@zash.se>
parents:
10358
diff
changeset
|
29 end |
4407
f78c6f5fa090
util.jid: Added escape() and unescape().
Waqas Hussain <waqas20@gmail.com>
parents:
3480
diff
changeset
|
30 |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
31 local _ENV = nil; |
8555
4f0f5b49bb03
vairious: Add annotation when an empty environment is set [luacheck]
Kim Alvefur <zash@zash.se>
parents:
7670
diff
changeset
|
32 -- luacheck: std none |
0 | 33 |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
34 local function split(jid) |
12190
3616128cd2e3
util.jid: Explicitly check for nil rather than falsy
Kim Alvefur <zash@zash.se>
parents:
11056
diff
changeset
|
35 if jid == nil then return; end |
3480
97831dfe7f72
util.jid: Fix parsing of JIDs with no nodepart and an @ in the resourcepart (thanks seth)
Matthew Wild <mwild1@gmail.com>
parents:
3375
diff
changeset
|
36 local node, nodepos = match(jid, "^([^@/]+)@()"); |
9324
607b262da853
util.jid: Add missing semicolon
Kim Alvefur <zash@zash.se>
parents:
8555
diff
changeset
|
37 local host, hostpos = match(jid, "^([^@/]+)()", nodepos); |
12190
3616128cd2e3
util.jid: Explicitly check for nil rather than falsy
Kim Alvefur <zash@zash.se>
parents:
11056
diff
changeset
|
38 if node ~= nil and host == nil then return nil, nil, nil; end |
369 | 39 local resource = match(jid, "^/(.+)$", hostpos); |
12190
3616128cd2e3
util.jid: Explicitly check for nil rather than falsy
Kim Alvefur <zash@zash.se>
parents:
11056
diff
changeset
|
40 if (host == nil) or ((resource == nil) and #jid >= hostpos) then return nil, nil, nil; end |
366
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
365
diff
changeset
|
41 return node, host, resource; |
0 | 42 end |
104
cfbd3b849f9e
Fixed: util/jid.lua now returns module object
Waqas Hussain <waqas20@gmail.com>
parents:
29
diff
changeset
|
43 |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
44 local function bare(jid) |
6891 | 45 local node, host = split(jid); |
12190
3616128cd2e3
util.jid: Explicitly check for nil rather than falsy
Kim Alvefur <zash@zash.se>
parents:
11056
diff
changeset
|
46 if node ~= nil and host ~= nil then |
6889
7f7920f2aebf
Backout 7e820979fd9b (broke tests)
Kim Alvefur <zash@zash.se>
parents:
6777
diff
changeset
|
47 return node.."@"..host; |
7f7920f2aebf
Backout 7e820979fd9b (broke tests)
Kim Alvefur <zash@zash.se>
parents:
6777
diff
changeset
|
48 end |
7f7920f2aebf
Backout 7e820979fd9b (broke tests)
Kim Alvefur <zash@zash.se>
parents:
6777
diff
changeset
|
49 return host; |
365
a59300fc22ec
Add jid.bare() helper function
Matthew Wild <mwild1@gmail.com>
parents:
109
diff
changeset
|
50 end |
a59300fc22ec
Add jid.bare() helper function
Matthew Wild <mwild1@gmail.com>
parents:
109
diff
changeset
|
51 |
10358
a77d9b3885bb
util.jid: Add a 'strict' flag for jidprep calls
Kim Alvefur <zash@zash.se>
parents:
9324
diff
changeset
|
52 local function prepped_split(jid, strict) |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
53 local node, host, resource = split(jid); |
12190
3616128cd2e3
util.jid: Explicitly check for nil rather than falsy
Kim Alvefur <zash@zash.se>
parents:
11056
diff
changeset
|
54 if host ~= nil and host ~= "." then |
5944
f3817912e8b2
util.jid: Strip trailing '.' when normalizing hostnames
Matthew Wild <mwild1@gmail.com>
parents:
4407
diff
changeset
|
55 if sub(host, -1, -1) == "." then -- Strip empty root label |
f3817912e8b2
util.jid: Strip trailing '.' when normalizing hostnames
Matthew Wild <mwild1@gmail.com>
parents:
4407
diff
changeset
|
56 host = sub(host, 1, -2); |
f3817912e8b2
util.jid: Strip trailing '.' when normalizing hostnames
Matthew Wild <mwild1@gmail.com>
parents:
4407
diff
changeset
|
57 end |
10358
a77d9b3885bb
util.jid: Add a 'strict' flag for jidprep calls
Kim Alvefur <zash@zash.se>
parents:
9324
diff
changeset
|
58 host = nameprep(host, strict); |
12190
3616128cd2e3
util.jid: Explicitly check for nil rather than falsy
Kim Alvefur <zash@zash.se>
parents:
11056
diff
changeset
|
59 if host == nil then return; end |
3616128cd2e3
util.jid: Explicitly check for nil rather than falsy
Kim Alvefur <zash@zash.se>
parents:
11056
diff
changeset
|
60 if node ~= nil then |
10358
a77d9b3885bb
util.jid: Add a 'strict' flag for jidprep calls
Kim Alvefur <zash@zash.se>
parents:
9324
diff
changeset
|
61 node = nodeprep(node, strict); |
12190
3616128cd2e3
util.jid: Explicitly check for nil rather than falsy
Kim Alvefur <zash@zash.se>
parents:
11056
diff
changeset
|
62 if node == nil then return; end |
717
ab428c579cbc
util/jid: string prepping functions added: prepped_split and prep
Waqas Hussain <waqas20@gmail.com>
parents:
615
diff
changeset
|
63 end |
12190
3616128cd2e3
util.jid: Explicitly check for nil rather than falsy
Kim Alvefur <zash@zash.se>
parents:
11056
diff
changeset
|
64 if resource ~= nil then |
10358
a77d9b3885bb
util.jid: Add a 'strict' flag for jidprep calls
Kim Alvefur <zash@zash.se>
parents:
9324
diff
changeset
|
65 resource = resourceprep(resource, strict); |
12190
3616128cd2e3
util.jid: Explicitly check for nil rather than falsy
Kim Alvefur <zash@zash.se>
parents:
11056
diff
changeset
|
66 if resource == nil then return; end |
717
ab428c579cbc
util/jid: string prepping functions added: prepped_split and prep
Waqas Hussain <waqas20@gmail.com>
parents:
615
diff
changeset
|
67 end |
ab428c579cbc
util/jid: string prepping functions added: prepped_split and prep
Waqas Hussain <waqas20@gmail.com>
parents:
615
diff
changeset
|
68 return node, host, resource; |
ab428c579cbc
util/jid: string prepping functions added: prepped_split and prep
Waqas Hussain <waqas20@gmail.com>
parents:
615
diff
changeset
|
69 end |
ab428c579cbc
util/jid: string prepping functions added: prepped_split and prep
Waqas Hussain <waqas20@gmail.com>
parents:
615
diff
changeset
|
70 end |
ab428c579cbc
util/jid: string prepping functions added: prepped_split and prep
Waqas Hussain <waqas20@gmail.com>
parents:
615
diff
changeset
|
71 |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
72 local function join(node, host, resource) |
12190
3616128cd2e3
util.jid: Explicitly check for nil rather than falsy
Kim Alvefur <zash@zash.se>
parents:
11056
diff
changeset
|
73 if host == nil then return end |
3616128cd2e3
util.jid: Explicitly check for nil rather than falsy
Kim Alvefur <zash@zash.se>
parents:
11056
diff
changeset
|
74 if node ~= nil and resource ~= nil then |
2245
df9e18f5c808
util.jid: Add join(node, host, resource) function to join the components and return nil if invalid
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
75 return node.."@"..host.."/"..resource; |
12190
3616128cd2e3
util.jid: Explicitly check for nil rather than falsy
Kim Alvefur <zash@zash.se>
parents:
11056
diff
changeset
|
76 elseif node ~= nil then |
2245
df9e18f5c808
util.jid: Add join(node, host, resource) function to join the components and return nil if invalid
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
77 return node.."@"..host; |
12190
3616128cd2e3
util.jid: Explicitly check for nil rather than falsy
Kim Alvefur <zash@zash.se>
parents:
11056
diff
changeset
|
78 elseif resource ~= nil then |
2245
df9e18f5c808
util.jid: Add join(node, host, resource) function to join the components and return nil if invalid
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
79 return host.."/"..resource; |
df9e18f5c808
util.jid: Add join(node, host, resource) function to join the components and return nil if invalid
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
80 end |
6338
736c388748fd
util.jid: Return early in join on invalid jids
Kim Alvefur <zash@zash.se>
parents:
5945
diff
changeset
|
81 return host; |
2245
df9e18f5c808
util.jid: Add join(node, host, resource) function to join the components and return nil if invalid
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
82 end |
6339
1c19464cde77
util.jid: Use existing join function in jid.prep
Kim Alvefur <zash@zash.se>
parents:
6338
diff
changeset
|
83 |
10358
a77d9b3885bb
util.jid: Add a 'strict' flag for jidprep calls
Kim Alvefur <zash@zash.se>
parents:
9324
diff
changeset
|
84 local function prep(jid, strict) |
a77d9b3885bb
util.jid: Add a 'strict' flag for jidprep calls
Kim Alvefur <zash@zash.se>
parents:
9324
diff
changeset
|
85 local node, host, resource = prepped_split(jid, strict); |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
86 return join(node, host, resource); |
6339
1c19464cde77
util.jid: Use existing join function in jid.prep
Kim Alvefur <zash@zash.se>
parents:
6338
diff
changeset
|
87 end |
2245
df9e18f5c808
util.jid: Add join(node, host, resource) function to join the components and return nil if invalid
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
88 |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
89 local function compare(jid, acl) |
3375
29e51e1c7c3d
util.jid: compare() added, with some tests.
Kim Alvefur <zash@zash.se>
parents:
2923
diff
changeset
|
90 -- compare jid to single acl rule |
29e51e1c7c3d
util.jid: compare() added, with some tests.
Kim Alvefur <zash@zash.se>
parents:
2923
diff
changeset
|
91 -- TODO compare to table of rules? |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
92 local jid_node, jid_host, jid_resource = split(jid); |
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
93 local acl_node, acl_host, acl_resource = split(acl); |
3375
29e51e1c7c3d
util.jid: compare() added, with some tests.
Kim Alvefur <zash@zash.se>
parents:
2923
diff
changeset
|
94 if ((acl_node ~= nil and acl_node == jid_node) or acl_node == nil) and |
29e51e1c7c3d
util.jid: compare() added, with some tests.
Kim Alvefur <zash@zash.se>
parents:
2923
diff
changeset
|
95 ((acl_host ~= nil and acl_host == jid_host) or acl_host == nil) and |
29e51e1c7c3d
util.jid: compare() added, with some tests.
Kim Alvefur <zash@zash.se>
parents:
2923
diff
changeset
|
96 ((acl_resource ~= nil and acl_resource == jid_resource) or acl_resource == nil) then |
29e51e1c7c3d
util.jid: compare() added, with some tests.
Kim Alvefur <zash@zash.se>
parents:
2923
diff
changeset
|
97 return true |
29e51e1c7c3d
util.jid: compare() added, with some tests.
Kim Alvefur <zash@zash.se>
parents:
2923
diff
changeset
|
98 end |
29e51e1c7c3d
util.jid: compare() added, with some tests.
Kim Alvefur <zash@zash.se>
parents:
2923
diff
changeset
|
99 return false |
29e51e1c7c3d
util.jid: compare() added, with some tests.
Kim Alvefur <zash@zash.se>
parents:
2923
diff
changeset
|
100 end |
29e51e1c7c3d
util.jid: compare() added, with some tests.
Kim Alvefur <zash@zash.se>
parents:
2923
diff
changeset
|
101 |
7296
1859e07ae082
util.jid+tests: Add simple helpers... node(), host() and resource() for extracting specific parts of a JID
Matthew Wild <mwild1@gmail.com>
parents:
6891
diff
changeset
|
102 local function node(jid) |
1859e07ae082
util.jid+tests: Add simple helpers... node(), host() and resource() for extracting specific parts of a JID
Matthew Wild <mwild1@gmail.com>
parents:
6891
diff
changeset
|
103 return (select(1, split(jid))); |
1859e07ae082
util.jid+tests: Add simple helpers... node(), host() and resource() for extracting specific parts of a JID
Matthew Wild <mwild1@gmail.com>
parents:
6891
diff
changeset
|
104 end |
1859e07ae082
util.jid+tests: Add simple helpers... node(), host() and resource() for extracting specific parts of a JID
Matthew Wild <mwild1@gmail.com>
parents:
6891
diff
changeset
|
105 |
1859e07ae082
util.jid+tests: Add simple helpers... node(), host() and resource() for extracting specific parts of a JID
Matthew Wild <mwild1@gmail.com>
parents:
6891
diff
changeset
|
106 local function host(jid) |
1859e07ae082
util.jid+tests: Add simple helpers... node(), host() and resource() for extracting specific parts of a JID
Matthew Wild <mwild1@gmail.com>
parents:
6891
diff
changeset
|
107 return (select(2, split(jid))); |
1859e07ae082
util.jid+tests: Add simple helpers... node(), host() and resource() for extracting specific parts of a JID
Matthew Wild <mwild1@gmail.com>
parents:
6891
diff
changeset
|
108 end |
1859e07ae082
util.jid+tests: Add simple helpers... node(), host() and resource() for extracting specific parts of a JID
Matthew Wild <mwild1@gmail.com>
parents:
6891
diff
changeset
|
109 |
1859e07ae082
util.jid+tests: Add simple helpers... node(), host() and resource() for extracting specific parts of a JID
Matthew Wild <mwild1@gmail.com>
parents:
6891
diff
changeset
|
110 local function resource(jid) |
1859e07ae082
util.jid+tests: Add simple helpers... node(), host() and resource() for extracting specific parts of a JID
Matthew Wild <mwild1@gmail.com>
parents:
6891
diff
changeset
|
111 return (select(3, split(jid))); |
1859e07ae082
util.jid+tests: Add simple helpers... node(), host() and resource() for extracting specific parts of a JID
Matthew Wild <mwild1@gmail.com>
parents:
6891
diff
changeset
|
112 end |
1859e07ae082
util.jid+tests: Add simple helpers... node(), host() and resource() for extracting specific parts of a JID
Matthew Wild <mwild1@gmail.com>
parents:
6891
diff
changeset
|
113 |
12605
053417068957
doap: Update XEP versions for which no code changes appear needed
Kim Alvefur <zash@zash.se>
parents:
12190
diff
changeset
|
114 -- TODO Forbid \20 at start and end of escaped output per XEP-0106 v1.1 |
11056
0b0a42542456
util.jid: Fix special escaping of '\' per XEP-0106
Kim Alvefur <zash@zash.se>
parents:
10358
diff
changeset
|
115 local function escape(s) return s and (s:gsub("\\%x%x", backslash_escapes):gsub("[\"&'/:<>@ ]", escapes)); end |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
116 local function unescape(s) return s and (s:gsub("\\%x%x", unescapes)); end |
4407
f78c6f5fa090
util.jid: Added escape() and unescape().
Waqas Hussain <waqas20@gmail.com>
parents:
3480
diff
changeset
|
117 |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
118 return { |
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
119 split = split; |
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
120 bare = bare; |
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
121 prepped_split = prepped_split; |
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
122 join = join; |
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
123 prep = prep; |
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
124 compare = compare; |
7296
1859e07ae082
util.jid+tests: Add simple helpers... node(), host() and resource() for extracting specific parts of a JID
Matthew Wild <mwild1@gmail.com>
parents:
6891
diff
changeset
|
125 node = node; |
1859e07ae082
util.jid+tests: Add simple helpers... node(), host() and resource() for extracting specific parts of a JID
Matthew Wild <mwild1@gmail.com>
parents:
6891
diff
changeset
|
126 host = host; |
1859e07ae082
util.jid+tests: Add simple helpers... node(), host() and resource() for extracting specific parts of a JID
Matthew Wild <mwild1@gmail.com>
parents:
6891
diff
changeset
|
127 resource = resource; |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
128 escape = escape; |
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
129 unescape = unescape; |
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6340
diff
changeset
|
130 }; |