($value)
| 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 | { |
no outgoing calls
no test coverage detected