summaryrefslogtreecommitdiff
path: root/src/mod_muc.erl
diff options
context:
space:
mode:
authorHAMANO Tsukasa <hamano@cuspy.org>2016-01-14 23:08:31 +0900
committerBadlop <badlop@process-one.net>2016-02-05 12:09:18 +0100
commit268f0b30ec4f085179ed7e53659463c241d8e0ee (patch)
tree250a0b94118d6acde693442e96ea4e9ba48606a3 /src/mod_muc.erl
parentMake hibernate timeouts configurable (diff)
add room_id_regexp option
Diffstat (limited to 'src/mod_muc.erl')
-rw-r--r--src/mod_muc.erl26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/mod_muc.erl b/src/mod_muc.erl
index f7c6d26d..c887b964 100644
--- a/src/mod_muc.erl
+++ b/src/mod_muc.erl
@@ -597,7 +597,8 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
case {Name, Type} of
{<<"presence">>, <<"">>} ->
case check_user_can_create_room(ServerHost,
- AccessCreate, From, Room) of
+ AccessCreate, From, Room) and
+ check_create_roomid(ServerHost, Room) of
true ->
{ok, Pid} = start_new_room(Host, ServerHost, Access,
Room, HistorySize,
@@ -628,17 +629,22 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
end.
check_user_can_create_room(ServerHost, AccessCreate,
- From, RoomID) ->
+ From, _RoomID) ->
case acl:match_rule(ServerHost, AccessCreate, From) of
- allow ->
- byte_size(RoomID) =<
- gen_mod:get_module_opt(ServerHost, ?MODULE, max_room_id,
- fun(infinity) -> infinity;
- (I) when is_integer(I), I>0 -> I
- end, infinity);
+ allow -> true;
_ -> false
end.
+check_create_roomid(ServerHost, RoomID) ->
+ Max = gen_mod:get_module_opt(ServerHost, ?MODULE, max_room_id,
+ fun(infinity) -> infinity;
+ (I) when is_integer(I), I>0 -> I
+ end, infinity),
+ Regexp = gen_mod:get_module_opt(ServerHost, ?MODULE, room_id_regexp,
+ fun iolist_to_binary/1, ""),
+ (byte_size(RoomID) =< Max) and
+ (re:run(RoomID, Regexp, [unicode, {capture, none}]) == match).
+
get_rooms(ServerHost, Host) ->
LServer = jid:nameprep(ServerHost),
get_rooms(LServer, Host,
@@ -1317,6 +1323,8 @@ mod_opt_type(max_room_id) ->
fun (infinity) -> infinity;
(I) when is_integer(I), I > 0 -> I
end;
+mod_opt_type(room_id_regexp) ->
+ fun iolist_to_binary/1;
mod_opt_type(max_room_name) ->
fun (infinity) -> infinity;
(I) when is_integer(I), I > 0 -> I
@@ -1342,7 +1350,7 @@ mod_opt_type(user_presence_shaper) ->
mod_opt_type(_) ->
[access, access_admin, access_create, access_persistent,
db_type, default_room_options, history_size, host,
- max_room_desc, max_room_id, max_room_name,
+ max_room_desc, max_room_id, max_room_name, room_id_regexp,
max_user_conferences, max_users,
max_users_admin_threshold, max_users_presence,
min_message_interval, min_presence_interval,