Improve sanitization of color inputs

This commit is contained in:
jrenslin committed 2021-01-30 22:56:00 +01:00
1 parent 89e06769f1
commit 7a252c6bfa
1 file changed
+3 -1
+3 -1
View File
@@ -98,7 +98,9 @@ public static function sanitize_rgb_color($input):string {
FILTER_SANITIZE_STRING,
FILTER_FLAG_NO_ENCODE_QUOTES);
if (!(preg_match('/^[a-zA-Z0-9]{3}$/', $output)) && !(preg_match('/^[a-zA-Z0-9]{6}$/', $output))) {
if ($output === false
|| ((preg_match('/^[a-zA-Z0-9]{3}$/', $output)) === false && (preg_match('/^[a-zA-Z0-9]{6}$/', $output)) === false)
) {
throw new MDInvalidColorCode("Invalid color code provided: " . $output);
}