19 public function validate($uri_string, $config, $context) {
24 if (strpos($uri_string,
'url(') !== 0)
return false;
25 $uri_string = substr($uri_string, 4);
26 $new_length = strlen($uri_string) - 1;
27 if ($uri_string[$new_length] !=
')')
return false;
28 $uri = trim(substr($uri_string, 0, $new_length));
30 if (!empty($uri) && ($uri[0] ==
"'" || $uri[0] ==
'"')) {
32 $new_length = strlen($uri) - 1;
33 if ($uri[$new_length] !== $quote)
return false;
34 $uri = substr($uri, 1, $new_length - 1);
41 if (
$result ===
false)
return false;
44 $result = str_replace(array(
'"',
"\\",
"\n",
"\x0c",
"\r"),
"",
$result);
48 $result = str_replace(array(
'(',
')',
"'"), array(
'%28',
'%29',
'%27'),
$result);
55 return "url(\"$result\")";