mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-24 12:18:51 +00:00
Merge branch 'develop-ascraeus' into develop
* develop-ascraeus: [ticket/12794] Properly validate google+ field against valid character set
This commit is contained in:
commit
bf25e31735
2 changed files with 44 additions and 12 deletions
|
@ -40,7 +40,7 @@ class type_googleplus extends type_string
|
|||
'field_length' => 20,
|
||||
'field_minlen' => 3,
|
||||
'field_maxlen' => 255,
|
||||
'field_validation' => '[\w]+',
|
||||
'field_validation' => '(?:(?!\.{2,})([^<>=+]))+',
|
||||
'field_novalue' => '',
|
||||
'field_default_value' => '',
|
||||
);
|
||||
|
|
|
@ -11,8 +11,27 @@
|
|||
*
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php';
|
||||
|
||||
class phpbb_profilefield_type_googleplus_test extends phpbb_test_case
|
||||
{
|
||||
protected $field;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$user = new \phpbb\user();
|
||||
$user->add_lang('ucp');
|
||||
$request = $this->getMock('\phpbb\request\request');
|
||||
$template = $this->getMock('\phpbb\template\template');
|
||||
|
||||
$this->field = new \phpbb\profilefields\type\type_googleplus(
|
||||
$request,
|
||||
$template,
|
||||
$user
|
||||
);
|
||||
}
|
||||
public function get_profile_contact_value_data()
|
||||
{
|
||||
return array(
|
||||
|
@ -36,16 +55,6 @@ class phpbb_profilefield_type_googleplus_test extends phpbb_test_case
|
|||
*/
|
||||
public function test_get_profile_contact_value($value, $field_options, $expected, $description)
|
||||
{
|
||||
$user = $this->getMock('\phpbb\user');
|
||||
$request = $this->getMock('\phpbb\request\request');
|
||||
$template = $this->getMock('\phpbb\template\template');
|
||||
|
||||
$field = new \phpbb\profilefields\type\type_googleplus(
|
||||
$request,
|
||||
$template,
|
||||
$user
|
||||
);
|
||||
|
||||
$default_field_options = array(
|
||||
'field_type' => '\phpbb\profilefields\type\type_googleplus',
|
||||
'field_name' => 'field',
|
||||
|
@ -57,6 +66,29 @@ class phpbb_profilefield_type_googleplus_test extends phpbb_test_case
|
|||
);
|
||||
$field_options = array_merge($default_field_options, $field_options);
|
||||
|
||||
$this->assertSame($expected, $field->get_profile_contact_value($value, $field_options), $description);
|
||||
$this->assertSame($expected, $this->field->get_profile_contact_value($value, $field_options), $description);
|
||||
}
|
||||
|
||||
public function data_validate_googleplus()
|
||||
{
|
||||
return array(
|
||||
array('foobar', false),
|
||||
array('2342340929304', false),
|
||||
array('foo<bar', 'The field “googleplus” has invalid characters.'),
|
||||
array('klkd.klkl', false),
|
||||
array('kl+', 'The field “googleplus” has invalid characters.'),
|
||||
array('foo=bar', 'The field “googleplus” has invalid characters.'),
|
||||
array('..foo', 'The field “googleplus” has invalid characters.'),
|
||||
array('foo..bar', 'The field “googleplus” has invalid characters.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider data_validate_googleplus
|
||||
*/
|
||||
public function test_validate_googleplus($input, $expected)
|
||||
{
|
||||
$field_data = array_merge(array('lang_name' => 'googleplus'), $this->field->get_default_option_values());
|
||||
$this->assertSame($expected, $this->field->validate_string_profile_field('string', $input, $field_data));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue