diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index beb7aefee5..3b0d53d52c 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -422,6 +422,13 @@ class acp_groups $error = array_merge($error, array_map(array(&$user, 'lang'), $max_recipients_error)); } + // 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/')))) + { + // Replace "error" string with its real, localised form + $error = array_merge($error, array_map(array(&$user, 'lang'), $colour_error)); + } + if (!sizeof($error)) { // Only set the rank, colour, etc. if it's changed or if we're adding a new diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 8ff76eac42..bf6af8b6f1 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -595,18 +595,11 @@ class ucp_groups $error[] = $user->lang['FORM_INVALID']; } - if (!empty($submit_ary['colour'])) + // 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/')))) { - preg_match('/^#?(?:[0-9a-fA-F]{6}|[0-9a-fA-F]{3})\b/', $submit_ary['colour'], $group_colour); - - if (sizeof($group_colour)) - { - $submit_ary['colour'] = (strpos($group_colour[0], '#') !== false) ? str_replace('#', '', $group_colour[0]) : $group_colour[0]; - } - else - { - $error[] = $user->lang['COLOUR_INVALID']; - } + // Replace "error" string with its real, localised form + $error = array_merge($error, array_map(array(&$user, 'lang'), $colour_error)); } if (!sizeof($error)) diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 129deb551c..c986e8213d 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -120,7 +120,6 @@ $lang = array_merge($lang, array( 'CLICK_VIEW_PRIVMSG' => '%sGo to your inbox%s', 'COLLAPSE_VIEW' => 'Collapse view', 'CLOSE_WINDOW' => 'Close window', - 'COLOUR_INVALID' => 'The colour value you entered is invalid.', 'COLOUR_SWATCH' => 'Colour swatch', 'COMMA_SEPARATOR' => ', ', // Used in pagination of ACP & prosilver, use localised comma if appropriate, eg: Ideographic or Arabic 'CONFIRM' => 'Confirm', @@ -723,6 +722,7 @@ $lang = array_merge($lang, array( 'WHO_IS_ONLINE' => 'Who is online', 'WRONG_PASSWORD' => 'You entered an incorrect password.', + 'WRONG_DATA_COLOUR' => 'The colour value you entered is invalid.', 'WRONG_DATA_ICQ' => 'The number you entered is not a valid ICQ number.', 'WRONG_DATA_JABBER' => 'The name you entered is not a valid Jabber account name.', 'WRONG_DATA_LANG' => 'The language you specified is not valid.', diff --git a/phpBB/styles/prosilver/template/ucp_groups_manage.html b/phpBB/styles/prosilver/template/ucp_groups_manage.html index 87b548c23b..d15cca8ee8 100644 --- a/phpBB/styles/prosilver/template/ucp_groups_manage.html +++ b/phpBB/styles/prosilver/template/ucp_groups_manage.html @@ -55,7 +55,7 @@

{L_GROUP_COLOR_EXPLAIN}
-
    [ {L_COLOUR_SWATCH} ]
+
    [ {L_COLOUR_SWATCH} ]
diff --git a/tests/functional/ucp_groups_test.php b/tests/functional/ucp_groups_test.php index d5ac6f697e..7a315c2018 100644 --- a/tests/functional/ucp_groups_test.php +++ b/tests/functional/ucp_groups_test.php @@ -15,15 +15,14 @@ class phpbb_functional_ucp_groups_test extends phpbb_functional_test_case public function groups_manage_test_data() { return array( - array('#AA0000', 'GROUP_UPDATED'), + array('#AA0000', 'WRONG_DATA_COLOUR'), array('AA0000', 'GROUP_UPDATED'), - array('AA0000v', 'COLOUR_INVALID'), - array('vAA0000', 'COLOUR_INVALID'), - array('AAG000', 'COLOUR_INVALID'), - array('#a00', 'GROUP_UPDATED'), - array('ag0', 'COLOUR_INVALID'), - array('#ag0', 'COLOUR_INVALID'), - array('##bcc', 'COLOUR_INVALID'), + array('AA0000v', 'WRONG_DATA_COLOUR'), + array('vAA0000', 'WRONG_DATA_COLOUR'), + array('AAG000','WRONG_DATA_COLOUR'), + array('a00', 'GROUP_UPDATED'), + array('ag0', 'WRONG_DATA_COLOUR'), + array('#aa0', 'WRONG_DATA_COLOUR'), ); }