From 7a252c6bfaffc56542b94c7422b5bda1aa05eb72 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Sat, 30 Jan 2021 22:56:00 +0100 Subject: [PATCH] Improve sanitization of color inputs --- MD_STD_IN.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MD_STD_IN.php b/MD_STD_IN.php index f2107cf..97aaaa7 100644 --- a/MD_STD_IN.php +++ b/MD_STD_IN.php @@ -98,7 +98,9 @@ final class MD_STD_IN { 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); }