Prevent room name using reserved word

master
Daniel Berteaud 11 years ago
parent a70fe3bc09
commit 0ee132334f
  1. 5
      public/vroom.pl

@ -205,13 +205,14 @@ helper ping_room => sub {
}; };
# Check if this name is a valid room name # 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 { helper valid_room_name => sub {
my $self = shift; my $self = shift;
my ($name) = @_; my ($name) = @_;
my $ret = undef; my $ret = undef;
my $len = length $name; 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; $ret = 1;
} }
return $ret; return $ret;

Loading…
Cancel
Save