1
0
mirror of https://github.com/dani/vroom.git synced 2024-06-18 12:19:13 +02:00

Prevent room name using reserved word

This commit is contained in:
Daniel Berteaud 2014-05-09 13:37:36 +02:00
parent a70fe3bc09
commit 0ee132334f

View File

@ -205,13 +205,14 @@ helper ping_room => sub {
};
# Check if this name is a valid room name
# TODO: reject if the name is the same as an existing route
helper valid_room_name => sub {
my $self = shift;
my ($name) = @_;
my $ret = undef;
my $len = length $name;
if ($len > 0 && $len < 50 && $name =~ m/^[\w\-]+$/){
# A few names are reserved
my @reserved = qw(about help feedback goodbye admin create localize action missing dies);
if ($len > 0 && $len < 50 && $name =~ m/^[\w\-]+$/ && !grep { $name eq $_ } @reserved){
$ret = 1;
}
return $ret;