diff --git a/lib/Lacuna/RPC/Empire.pm b/lib/Lacuna/RPC/Empire.pm index a0f38a56..088272a7 100644 --- a/lib/Lacuna/RPC/Empire.pm +++ b/lib/Lacuna/RPC/Empire.pm @@ -48,6 +48,7 @@ sub is_name_valid { ->not_empty ->no_padding ->no_restricted_chars + ->no_match(qr/^#/) ->no_profanity; return 1; } @@ -71,7 +72,15 @@ sub login { unless ($api_key) { confess [1002, 'You need an API Key.']; } - my $empire = Lacuna->db->resultset('Empire')->search({name=>$name})->next; + my $empire; + if ($name =~ /^#(-?\d+)$/) + { + $empire = Lacuna->db->resultset('Empire')->find({id=>$1}); + } + else + { + $empire = Lacuna->db->resultset('Empire')->find({name=>$name}); + } unless (defined $empire) { confess [1002, 'Empire does not exist.', $name]; } diff --git a/lib/Lacuna/Verify.pm b/lib/Lacuna/Verify.pm index e081a8bb..133bb756 100644 --- a/lib/Lacuna/Verify.pm +++ b/lib/Lacuna/Verify.pm @@ -59,6 +59,12 @@ sub no_restricted_chars { return $self->ok(${$self->content} !~ m/[@&<>;\{\}\(\)]/); } +sub no_match { + my $self = shift; + my $re = shift; + return $self->ok(${$self->content} !~ $re); +} + sub no_padding { my $self = shift; return $self->ok(${$self->content} !~ m/^\s/ && ${$self->content} !~ m/\s\s/ && ${$self->content} !~ m/\s$/); diff --git a/var/www/public/changes.txt b/var/www/public/changes.txt index 34b681b2..71c3b24b 100644 --- a/var/www/public/changes.txt +++ b/var/www/public/changes.txt @@ -7,6 +7,8 @@ - Fix: Most buildings should no longer ignore uni level. - Add: Overheating Parliament does damage. - Fix: Buildings should no longer get stuck in upgrading state. + - Add: Allow login with "#". + - Mod: "#" no longer permitted as leading character in empire names. 3.0908: - Mod: trash_messages_where now defaults to not returning deleted message IDs.