fix player name rule
This commit is contained in:
parent
2c579a4043
commit
3f7ba49c2c
|
|
@ -22,7 +22,7 @@ class PlayerName implements Rule
|
|||
break;
|
||||
|
||||
case 'utf8':
|
||||
return mb_check_encoding($value, 'UTF-8');
|
||||
return mb_check_encoding($value, 'UTF-8') && !preg_match('/\s/', $value);
|
||||
|
||||
case 'custom':
|
||||
$regexp = option('custom_player_name_regexp') ?: $regexp;
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ general:
|
|||
title: Player Name Rule
|
||||
official: Letters, numbers and underscores (Mojang's official rule)
|
||||
cjk: Allow CJK Unified Ideographs
|
||||
utf8: Allow all valid UTF-8 characters
|
||||
utf8: Allow all valid UTF-8 characters (excluding whitespaces)
|
||||
custom: Use custom rules (regular expression)
|
||||
custom_player_name_regexp:
|
||||
title: Custom Player Name Rules
|
||||
|
|
|
|||
|
|
@ -43,6 +43,24 @@ class PlayerNameTest extends TestCase
|
|||
);
|
||||
}
|
||||
|
||||
public function testUtf8()
|
||||
{
|
||||
option(['player_name_rule' => 'utf8']);
|
||||
$rule = new PlayerName();
|
||||
|
||||
$this->assertTrue($rule->passes('', '_name_'));
|
||||
$this->assertTrue($rule->passes('', 'NaN'));
|
||||
$this->assertTrue($rule->passes('', '中文'));
|
||||
$this->assertTrue($rule->passes('', '§Me'));
|
||||
$this->assertTrue($rule->passes('', ';'));
|
||||
$this->assertTrue($rule->passes('', '\\'));
|
||||
|
||||
$this->assertFalse($rule->passes('', 'a b'));
|
||||
$this->assertFalse($rule->passes('', "a\n b"));
|
||||
$this->assertFalse($rule->passes('', "a\tb"));
|
||||
$this->assertFalse($rule->passes('', "a\fb"));
|
||||
}
|
||||
|
||||
public function testCustom()
|
||||
{
|
||||
option(['player_name_rule' => 'custom']);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user