MCPcopy Create free account
hub / github.com/error311/FileRise / sanitizeColorHex

Method sanitizeColorHex

src/FileRise/Domain/AdminModel.php:739–764  ·  view source on GitHub ↗
($value)

Source from the content-addressed store, hash-verified

737 }
738
739 private static function sanitizeColorHex($value): string
740 {
741 $value = trim((string)$value);
742 if ($value === '') {
743 return '';
744 }
745
746 // allow #RGB or #RRGGBB (or without leading #)
747 if (preg_match('/^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/', $value, $m)) {
748 return '#' . strtoupper($m[1]);
749 }
750
751 // allow basic rgb()/rgba()/hsl()/hsla() syntaxes
752 $clean = preg_replace('/\s+/', ' ', $value);
753 if (preg_match('/^(rgb|rgba|hsl|hsla)\([0-9%.,\s]+\)$/i', $clean)) {
754 return $clean;
755 }
756
757 // allow a few safe keywords
758 $lower = strtolower($clean);
759 $keywords = ['transparent', 'black', 'white', 'red', 'green', 'blue', 'gray', 'grey'];
760 if (in_array($lower, $keywords, true)) {
761 return $lower;
762 }
763 return '';
764 }
765
766 private static function sanitizeMetaDescription($value): string
767 {

Callers 3

buildPublicSubsetMethod · 0.95
updateConfigMethod · 0.95
getConfigMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected