aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_user.php
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2013-05-19 17:45:45 +0200
committerMarc Alexander <admin@m-a-styles.de>2013-05-19 17:45:45 +0200
commitcd1da92d8540d6b4aa0fa1ccf2bcafe68007288a (patch)
treefb0eaa2dc6fc2ca3540fa8a9717cab7daa467714 /phpBB/includes/functions_user.php
parente49b4543de7c18df7e9b5c70ef5064cc4de9934a (diff)
downloadforums-cd1da92d8540d6b4aa0fa1ccf2bcafe68007288a.tar
forums-cd1da92d8540d6b4aa0fa1ccf2bcafe68007288a.tar.gz
forums-cd1da92d8540d6b4aa0fa1ccf2bcafe68007288a.tar.bz2
forums-cd1da92d8540d6b4aa0fa1ccf2bcafe68007288a.tar.xz
forums-cd1da92d8540d6b4aa0fa1ccf2bcafe68007288a.zip
[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
Diffstat (limited to 'phpBB/includes/functions_user.php')
-rw-r--r--phpBB/includes/functions_user.php8
1 files changed, 5 insertions, 3 deletions
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index f8e1fcaa45..61972c3876 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -1903,14 +1903,16 @@ function validate_jabber($jid)
* Validate hex colour value
*
* @param string $colour The hex colour value
-* @return bool|string Error message if colour value is incorrect, false if it
+* @param bool $optional Whether the colour value is optional. True if an empty
+* string will be accepted as correct input, false if not.
+* @return bool|string Error message if colour value is incorrect, false if it
* fits the hex colour code
*/
-function phpbb_validate_hex_colour($colour)
+function phpbb_validate_hex_colour($colour, $optional = false)
{
if (empty($colour))
{
- return false;
+ return (($optional) ? false : 'WRONG_DATA');
}
if (!preg_match('/^([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/', $colour))