13 for ($c =
'a'; $c <=
'z'; $c++) $this->mask .= $c;
14 for ($c =
'A'; $c <=
'Z'; $c++) $this->mask .= $c;
15 for ($c =
'0'; $c <=
'9'; $c++) $this->mask .= $c;
17 for ($i = 0x80; $i <= 0xFF; $i++) {
21 $this->mask .= chr($i);
42 public function validate($string, $config, $context) {
43 static $generic_names = array(
50 $allowed_fonts = $config->get(
'CSS.AllowedFonts');
53 $fonts = explode(
',', $string);
55 foreach($fonts as $font) {
57 if ($font ===
'')
continue;
59 if (isset($generic_names[$font])) {
60 if ($allowed_fonts === null || isset($allowed_fonts[$font])) {
61 $final .= $font .
', ';
66 if ($font[0] ===
'"' || $font[0] ===
"'") {
67 $length = strlen($font);
68 if ($length <= 2)
continue;
70 if ($font[$length - 1] !== $quote)
continue;
71 $font = substr($font, 1, $length - 2);
78 if ($allowed_fonts !== null && !isset($allowed_fonts[$font])) {
82 if (ctype_alnum($font) && $font !==
'') {
84 $final .= $font .
', ';
90 $font = str_replace(array(
"\n",
"\t",
"\r",
"\x0C"),
' ', $font);
171 if (strspn($font, $this->mask) !== strlen($font)) {
188 $final .=
"'$font', ";
190 $final = rtrim($final,
', ');
191 if ($final ===
'')
return false;