mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
Merge pull request #3166 from nickvergessen/Senky-ticket/12866
[ticket/12866] Wrong profile field validation options
This commit is contained in:
commit
67c987f0d0
3 changed files with 70 additions and 11 deletions
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace phpbb\db\migration\data\v31x;
|
||||||
|
|
||||||
|
class profilefield_remove_underscore_from_alpha extends \phpbb\db\migration\migration
|
||||||
|
{
|
||||||
|
static public function depends_on()
|
||||||
|
{
|
||||||
|
return array('\phpbb\db\migration\data\v31x\v311');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update_data()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('custom', array(array($this, 'remove_underscore_from_alpha_validations'))),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function remove_underscore_from_alpha_validations()
|
||||||
|
{
|
||||||
|
$this->update_validation_rule('[\w]+', '[a-zA-Z0-9]+');
|
||||||
|
$this->update_validation_rule('[\w_]+', '[\w]+');
|
||||||
|
$this->update_validation_rule('[\w.]+', '[a-zA-Z0-9.]+');
|
||||||
|
$this->update_validation_rule('[\w\x20_+\-\[\]]+', '[\w\x20+\-\[\]]+');
|
||||||
|
$this->update_validation_rule('[a-zA-Z][\w\.,\-_]+', '[a-zA-Z][\w\.,\-]+');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update_validation_rule($old_validation, $new_validation)
|
||||||
|
{
|
||||||
|
$sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . "
|
||||||
|
SET field_validation = '" . $this->db->sql_escpape($new_validation) . "'
|
||||||
|
WHERE field_validation = '" . $this->db->sql_escpape($old_validation) . "'";
|
||||||
|
$this->db->sql_query($sql);
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,11 +18,11 @@ abstract class type_string_common extends type_base
|
||||||
protected $validation_options = array(
|
protected $validation_options = array(
|
||||||
'CHARS_ANY' => '.*',
|
'CHARS_ANY' => '.*',
|
||||||
'NUMBERS_ONLY' => '[0-9]+',
|
'NUMBERS_ONLY' => '[0-9]+',
|
||||||
'ALPHA_ONLY' => '[\w]+',
|
'ALPHA_ONLY' => '[a-zA-Z0-9]+',
|
||||||
'ALPHA_UNDERSCORE' => '[\w_]+',
|
'ALPHA_UNDERSCORE' => '[\w]+',
|
||||||
'ALPHA_DOTS' => '[\w.]+',
|
'ALPHA_DOTS' => '[a-zA-Z0-9.]+',
|
||||||
'ALPHA_SPACERS' => '[\w\x20_+\-\[\]]+',
|
'ALPHA_SPACERS' => '[\w\x20+\-\[\]]+',
|
||||||
'ALPHA_PUNCTUATION' => '[a-zA-Z][\w\.,\-_]+',
|
'ALPHA_PUNCTUATION' => '[a-zA-Z][\w\.,\-]+',
|
||||||
'LETTER_NUM_ONLY' => '[\p{Lu}\p{Ll}0-9]+',
|
'LETTER_NUM_ONLY' => '[\p{Lu}\p{Ll}0-9]+',
|
||||||
'LETTER_NUM_UNDERSCORE' => '[\p{Lu}\p{Ll}0-9_]+',
|
'LETTER_NUM_UNDERSCORE' => '[\p{Lu}\p{Ll}0-9_]+',
|
||||||
'LETTER_NUM_DOTS' => '[\p{Lu}\p{Ll}0-9.]+',
|
'LETTER_NUM_DOTS' => '[\p{Lu}\p{Ll}0-9.]+',
|
||||||
|
|
|
@ -133,37 +133,49 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'ö äö äö ä',
|
'ö äö äö ä',
|
||||||
array('field_validation' => '[\w]+'),
|
array('field_validation' => '[a-zA-Z0-9]+'),
|
||||||
'FIELD_INVALID_CHARS_ALPHA_ONLY-field',
|
'FIELD_INVALID_CHARS_ALPHA_ONLY-field',
|
||||||
'Required field should reject UTF-8 in 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(
|
array(
|
||||||
'Hello',
|
'Hello',
|
||||||
array('field_validation' => '[\w]+'),
|
array('field_validation' => '[a-zA-Z0-9]+'),
|
||||||
false,
|
false,
|
||||||
'Required field should accept a characters only field',
|
'Required field should accept a characters only field',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'Valid.Username123',
|
'Valid.Username123',
|
||||||
array('field_validation' => '[\w.]+'),
|
array('field_validation' => '[a-zA-Z0-9.]+'),
|
||||||
false,
|
false,
|
||||||
'Required field should accept a alphanumeric field with dots',
|
'Required field should accept a alphanumeric field with dots',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'Invalid.,username123',
|
'Invalid.,username123',
|
||||||
array('field_validation' => '[\w.]+'),
|
array('field_validation' => '[a-zA-Z0-9.]+'),
|
||||||
'FIELD_INVALID_CHARS_ALPHA_DOTS-field',
|
'FIELD_INVALID_CHARS_ALPHA_DOTS-field',
|
||||||
'Required field should reject field with comma',
|
'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(
|
array(
|
||||||
'skype.test.name,_this',
|
'skype.test.name,_this',
|
||||||
array('field_validation' => '[a-zA-Z][\w\.,\-_]+'),
|
array('field_validation' => '[a-zA-Z][\w\.,\-]+'),
|
||||||
false,
|
false,
|
||||||
'Required field should accept alphanumeric field with punctuations',
|
'Required field should accept alphanumeric field with punctuations',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'1skype.this.should.faila',
|
'1skype.this.should.faila',
|
||||||
array('field_validation' => '[a-zA-Z][\w\.,\-_]+'),
|
array('field_validation' => '[a-zA-Z][\w\.,\-]+'),
|
||||||
'FIELD_INVALID_CHARS_ALPHA_PUNCTUATION-field',
|
'FIELD_INVALID_CHARS_ALPHA_PUNCTUATION-field',
|
||||||
'Required field should reject field having invalid input for the given validation',
|
'Required field should reject field having invalid input for the given validation',
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Reference in a new issue