diff --git a/app/img/devices/compute.php b/app/img/devices/compute.php index bf744a3a..63ddeb44 100644 --- a/app/img/devices/compute.php +++ b/app/img/devices/compute.php @@ -8,78 +8,78 @@ $color = getColorOpt(); viewBox="0 0 291.5 203.2" style="enable-background:new 0 0 291.5 203.2;" xml:space="preserve"> diff --git a/includes/functions.php b/includes/functions.php index f1b90b9e..a3e53ef6 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -664,6 +664,16 @@ function getColorOpt() } else { $color = $_COOKIE['color']; } + + // Define the regex pattern for valid CSS color formats + $colorPattern = "/^(#([a-fA-F0-9]{3}|[a-fA-F0-9]{6})|rgb\((\s*\d+\s*,){2}\s*\d+\s*\)|rgba\((\s*\d+\s*,){3}\s*(0|0\.\d+|1)\)|[a-zA-Z]+)$/i"; + + // Validate the color + if (!preg_match($colorPattern, $color)) { + // Return a default color if validation fails + $color = "#2b8080"; + } + return $color; }