diff --git a/phpBB/phpbb/profilefields/type/type_string_common.php b/phpBB/phpbb/profilefields/type/type_string_common.php index ff33a7b49c..f5e1992044 100644 --- a/phpBB/phpbb/profilefields/type/type_string_common.php +++ b/phpBB/phpbb/profilefields/type/type_string_common.php @@ -18,11 +18,11 @@ abstract class type_string_common extends type_base protected $validation_options = array( 'CHARS_ANY' => '.*', 'NUMBERS_ONLY' => '[0-9]+', - 'ALPHA_ONLY' => '[\w]+', - 'ALPHA_UNDERSCORE' => '[\w_]+', - 'ALPHA_DOTS' => '[\w.]+', - 'ALPHA_SPACERS' => '[\w\x20_+\-\[\]]+', - 'ALPHA_PUNCTUATION' => '[a-zA-Z][\w\.,\-_]+', + 'ALPHA_ONLY' => '[a-zA-Z0-9]+', + 'ALPHA_UNDERSCORE' => '[\w]+', + 'ALPHA_DOTS' => '[a-zA-Z0-9.]+', + 'ALPHA_SPACERS' => '[\w\x20+\-\[\]]+', + 'ALPHA_PUNCTUATION' => '[a-zA-Z][\w\.,\-]+', 'LETTER_NUM_ONLY' => '[\p{Lu}\p{Ll}0-9]+', 'LETTER_NUM_UNDERSCORE' => '[\p{Lu}\p{Ll}0-9_]+', 'LETTER_NUM_DOTS' => '[\p{Lu}\p{Ll}0-9.]+', diff --git a/tests/profilefields/type_string_test.php b/tests/profilefields/type_string_test.php index a7be087fb5..0417afbfab 100644 --- a/tests/profilefields/type_string_test.php +++ b/tests/profilefields/type_string_test.php @@ -133,37 +133,49 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case ), array( 'ö äö äö ä', - array('field_validation' => '[\w]+'), + array('field_validation' => '[a-zA-Z0-9]+'), 'FIELD_INVALID_CHARS_ALPHA_ONLY-field', 'Required field should reject UTF-8 in alpha only field', ), + array( + 'a_abc', + array('field_validation' => '[a-zA-Z0-9]+'), + 'FIELD_INVALID_CHARS_ALPHA_ONLY-field', + 'Required field should reject underscore in alpha only field', + ), array( 'Hello', - array('field_validation' => '[\w]+'), + array('field_validation' => '[a-zA-Z0-9]+'), false, 'Required field should accept a characters only field', ), array( 'Valid.Username123', - array('field_validation' => '[\w.]+'), + array('field_validation' => '[a-zA-Z0-9.]+'), false, 'Required field should accept a alphanumeric field with dots', ), array( 'Invalid.,username123', - array('field_validation' => '[\w.]+'), + array('field_validation' => '[a-zA-Z0-9.]+'), 'FIELD_INVALID_CHARS_ALPHA_DOTS-field', 'Required field should reject field with comma', ), + array( + 'Invalid._username123', + array('field_validation' => '[a-zA-Z0-9.]+'), + 'FIELD_INVALID_CHARS_ALPHA_DOTS-field', + 'Required field should reject field with underscore', + ), array( 'skype.test.name,_this', - array('field_validation' => '[a-zA-Z][\w\.,\-_]+'), + array('field_validation' => '[a-zA-Z][\w\.,\-]+'), false, 'Required field should accept alphanumeric field with punctuations', ), array( '1skype.this.should.faila', - array('field_validation' => '[a-zA-Z][\w\.,\-_]+'), + array('field_validation' => '[a-zA-Z][\w\.,\-]+'), 'FIELD_INVALID_CHARS_ALPHA_PUNCTUATION-field', 'Required field should reject field having invalid input for the given validation', ),