diff options
author | Marc Alexander <admin@m-a-styles.de> | 2013-05-14 22:39:33 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2013-05-14 22:39:33 +0200 |
commit | deefe5c0e48534cea1327cf685255d109d9d7e2c (patch) | |
tree | 40c4fa50563626043ebbcefde191ab92d8f1b54c /phpBB/includes/ucp | |
parent | 1fae7720e43c8ff853225e16d0de54395d9ab051 (diff) | |
download | forums-deefe5c0e48534cea1327cf685255d109d9d7e2c.tar forums-deefe5c0e48534cea1327cf685255d109d9d7e2c.tar.gz forums-deefe5c0e48534cea1327cf685255d109d9d7e2c.tar.bz2 forums-deefe5c0e48534cea1327cf685255d109d9d7e2c.tar.xz forums-deefe5c0e48534cea1327cf685255d109d9d7e2c.zip |
[ticket/11538] Simplify colour value check and remove support for '#'
The input length for the hex color is now limited to 6 characters and
the support for colors starting with a '#' has been dropped. The allowed
input length of 7 in prosilver seems to have been a relict from old ages
of phpBB3. In order to have proper support for correct checking of the
colour value, the new code was also ported to the ACP groups manage page.
The tests have been modified to reflect the changes to the behavior of
the color check. Tests for the ACP will follow.
PHPBB3-11538
Diffstat (limited to 'phpBB/includes/ucp')
-rw-r--r-- | phpBB/includes/ucp/ucp_groups.php | 15 |
1 files changed, 4 insertions, 11 deletions
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)) |