diff options
author | Marc Alexander <admin@m-a-styles.de> | 2013-05-14 19:44:55 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2013-05-14 19:44:55 +0200 |
commit | a547ba3f9d569410107574a151af9a2f301bb68e (patch) | |
tree | 215f6f6bd13471a09f0ff3d55e3bccb174700f5f /phpBB/includes | |
parent | b7b0b0ccc3fbf92324948e8c5e616a3e06343600 (diff) | |
download | forums-a547ba3f9d569410107574a151af9a2f301bb68e.tar forums-a547ba3f9d569410107574a151af9a2f301bb68e.tar.gz forums-a547ba3f9d569410107574a151af9a2f301bb68e.tar.bz2 forums-a547ba3f9d569410107574a151af9a2f301bb68e.tar.xz forums-a547ba3f9d569410107574a151af9a2f301bb68e.zip |
[ticket/11538] Use regex for testing color value and improve tests
We are now using a regex with preg_match() in order to properly check
if the entered color value is in hex color format or not. A proper
error message is triggered if an incorrect color value is entered and
the prepended '#' is removed if necessary.
PHPBB3-11538
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/ucp/ucp_groups.php | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index c1db19774a..3f06e74159 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -595,18 +595,22 @@ class ucp_groups $error[] = $user->lang['FORM_INVALID']; } - if (!sizeof($error)) + if (!empty($submit_ary['colour'])) { - // Make sure maximum length of 6 of group color is not exceeded - if (strpos($submit_ary['colour'], '#') === 0) + 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'] = substr($submit_ary['colour'], 1, 6); + $submit_ary['colour'] = (strpos($group_colour[0], '#') !== false) ? str_replace('#', '', $group_colour[0]) : $group_colour[0]; } else { - $submit_ary['colour'] = substr($submit_ary['colour'], 0, 6); + $error[] = $user->lang['COLOUR_INVALID']; } + } + if (!sizeof($error)) + { // Only set the rank, colour, etc. if it's changed or if we're adding a new // group. This prevents existing group members being updated if no changes // were made. |