From deefe5c0e48534cea1327cf685255d109d9d7e2c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 14 May 2013 22:39:33 +0200 Subject: [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 --- phpBB/includes/acp/acp_groups.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'phpBB/includes/acp') 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 -- cgit v1.2.1 From 204cdb21640aead9f7560034bb8e686c17707476 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 15 May 2013 12:30:05 +0200 Subject: [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 --- phpBB/includes/acp/acp_groups.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/acp') diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 3b0d53d52c..ffbce33667 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -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)); -- cgit v1.2.1 From 1715619fda2aebd7ebae960e5fcbdf4b24ce4dca Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 16 May 2013 13:22:43 +0200 Subject: [ticket/11538] Add function phpbb_validate_colour for validating colours It will be possible to use this function via the validate_data() function interface that has already been used previously. Thus, this new function will extend the capabilities of validate_data() to checking hex color values. PHPBB3-11538 --- phpBB/includes/acp/acp_groups.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/acp') diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index ffbce33667..9a9a723605 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -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})$/')))) + if ($colour_error = validate_data($submit_ary, array('colour' => array('colour')))) { // Replace "error" string with its real, localised form $error = array_merge($error, array_map(array(&$user, 'lang'), $colour_error)); -- cgit v1.2.1 From b49ce5eb3a54a6c256955d3510fe409a6f4511aa Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 19 May 2013 11:29:11 +0200 Subject: [ticket/11538] Rename phpbb_validate_colour to phpbb_validate_hex_colour PHPBB3-11538 --- phpBB/includes/acp/acp_groups.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/acp') diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 9a9a723605..25df9e357e 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -423,7 +423,7 @@ class acp_groups } // Validate submitted colour value - if ($colour_error = validate_data($submit_ary, array('colour' => array('colour')))) + if ($colour_error = validate_data($submit_ary, array('colour' => array('hex_colour')))) { // Replace "error" string with its real, localised form $error = array_merge($error, array_map(array(&$user, 'lang'), $colour_error)); -- cgit v1.2.1 From 373e26ca746699f466e768406b951e6cf09ed284 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 19 May 2013 11:38:11 +0200 Subject: [ticket/11538] Merge calls to validate_data() in acp_groups PHPBB3-11538 --- phpBB/includes/acp/acp_groups.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'phpBB/includes/acp') diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 25df9e357e..bddad78bf2 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -413,20 +413,21 @@ class acp_groups } } - // Validate the length of "Maximum number of allowed recipients per private message" setting. - // We use 16777215 as a maximum because it matches MySQL unsigned mediumint maximum value - // which is the lowest amongst DBMSes supported by phpBB3 - if ($max_recipients_error = validate_data($submit_ary, array('max_recipients' => array('num', false, 0, 16777215)))) - { - // Replace "error" string with its real, localised form - $error = array_merge($error, array_map(array(&$user, 'lang'), $max_recipients_error)); - } + /* + * Validate the length of "Maximum number of allowed recipients per private message" setting. + * We use 16777215 as a maximum because it matches MySQL unsigned mediumint maximum value + * which is the lowest amongst DBMSes supported by phpBB3. + * Also validate the submitted colour value. + */ + $validation_checks = array( + 'max_recipients' => array('num', false, 0, 16777215), + 'colour' => array('hex_colour'), + ); - // Validate submitted colour value - if ($colour_error = validate_data($submit_ary, array('colour' => array('hex_colour')))) + if ($validation_error = validate_data($submit_ary, $validation_checks)) { // Replace "error" string with its real, localised form - $error = array_merge($error, array_map(array(&$user, 'lang'), $colour_error)); + $error = array_merge($error, array_map(array(&$user, 'lang'), $validation_error)); } if (!sizeof($error)) -- cgit v1.2.1 From 7898dd945966232060bf4ff39a31b319f4962ae1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 19 May 2013 15:13:37 +0200 Subject: [ticket/11538] Limit comment in acp_groups to 80 characters per line PHPBB3-11538 --- phpBB/includes/acp/acp_groups.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/acp') diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index bddad78bf2..089fe4baa1 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -414,10 +414,10 @@ class acp_groups } /* - * Validate the length of "Maximum number of allowed recipients per private message" setting. - * We use 16777215 as a maximum because it matches MySQL unsigned mediumint maximum value - * which is the lowest amongst DBMSes supported by phpBB3. - * Also validate the submitted colour value. + * Validate the length of "Maximum number of allowed recipients per + * private message" setting. We use 16777215 as a maximum because it matches + * MySQL unsigned mediumint maximum value which is the lowest amongst DBMSes + * supported by phpBB3. Also validate the submitted colour value. */ $validation_checks = array( 'max_recipients' => array('num', false, 0, 16777215), -- cgit v1.2.1 From cd1da92d8540d6b4aa0fa1ccf2bcafe68007288a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 19 May 2013 17:45:45 +0200 Subject: [ticket/11538] Add optional switch as argument to hex colour validation The value of $optional will decide whether an empty string will be treated as incorrect input or if it is allowed. The optional argument will default to false and therefore treat an empty string as incorrect unless explicitly told to not do so. PHPBB3-11538 --- phpBB/includes/acp/acp_groups.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/acp') diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 089fe4baa1..83c355540e 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -421,7 +421,7 @@ class acp_groups */ $validation_checks = array( 'max_recipients' => array('num', false, 0, 16777215), - 'colour' => array('hex_colour'), + 'colour' => array('hex_colour', true), ); if ($validation_error = validate_data($submit_ary, $validation_checks)) -- cgit v1.2.1