mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-12-26 23:26:47 +01:00
fix(color): add validation for CSS color formats in getColorOpt function
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user