[ticket/11538] Make sure regex doesn't allow multiple color values

This will now make sure that 'AAFF00' will be matched but strings like
'AAFF00 AABB00' will not.

PHPBB3-11538
This commit is contained in:
Marc Alexander 2013-05-15 12:30:05 +02:00
parent cbe4a3c3b6
commit 204cdb2164
4 changed files with 8 additions and 2 deletions

View file

@ -423,7 +423,7 @@ class acp_groups
}
// Validate submitted colour value
if ($colour_error = validate_data($submit_ary, array('colour' => array('match', true, '/^([0-9a-fA-F]{6}|[0-9a-fA-F]{3})\b/'))))
if ($colour_error = validate_data($submit_ary, array('colour' => array('match', true, '/^([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/'))))
{
// Replace "error" string with its real, localised form
$error = array_merge($error, array_map(array(&$user, 'lang'), $colour_error));

View file

@ -596,7 +596,7 @@ class ucp_groups
}
// Validate submitted colour value
if ($colour_error = validate_data($submit_ary, array('colour' => array('match', true, '/^([0-9a-fA-F]{6}|[0-9a-fA-F]{3})\b/'))))
if ($colour_error = validate_data($submit_ary, array('colour' => array('match', true, '/^([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/'))))
{
// Replace "error" string with its real, localised form
$error = array_merge($error, array_map(array(&$user, 'lang'), $colour_error));

View file

@ -23,6 +23,9 @@ class phpbb_functional_acp_groups_test extends phpbb_functional_test_case
array('a00', 'GROUP_UPDATED'),
array('ag0', 'WRONG_DATA_COLOUR'),
array('#aa0', 'WRONG_DATA_COLOUR'),
array('AA0000 ', 'GROUP_UPDATED'),
array('AA0000 abf', 'WRONG_DATA_COLOUR'),
array('AA0000 AA0000', 'WRONG_DATA_COLOUR'),
);
}

View file

@ -23,6 +23,9 @@ class phpbb_functional_ucp_groups_test extends phpbb_functional_test_case
array('a00', 'GROUP_UPDATED'),
array('ag0', 'WRONG_DATA_COLOUR'),
array('#aa0', 'WRONG_DATA_COLOUR'),
array('AA0000 ', 'GROUP_UPDATED'),
array('AA0000 abf', 'WRONG_DATA_COLOUR'),
array('AA0000 AA0000', 'WRONG_DATA_COLOUR'),
);
}