Source for file URI.php
Documentation is available at URI.php
* Validates a URI in CSS syntax, which uses url('http://example.com')
* @note While theoretically speaking a URI in a CSS document could
* be non-embedded, as of CSS2 there is no such usage so we're
* generalizing it. This may need to be changed in the future.
* @warning Since HTMLPurifier_AttrDef_CSS blindly uses semicolons as
* the separator, you cannot put a literal semicolon in
* in the URI. Try percent encoding it, in that case.
public function validate($uri_string, $config, $context) {
// parse the URI out of the string and then pass it onto
if (strpos($uri_string, 'url(') !==
0) return false;
$uri_string =
substr($uri_string, 4);
$new_length =
strlen($uri_string) -
1;
if ($uri_string[$new_length] !=
')') return false;
if (!empty($uri) &&
($uri[0] ==
"'" ||
$uri[0] ==
'"')) {
$new_length =
strlen($uri) -
1;
if ($uri[$new_length] !==
$quote) return false;
$uri =
substr($uri, 1, $new_length -
1);
$keys =
array( '(', ')', ',', ' ', '"', "'");
$values =
array('\\(', '\\)', '\\,', '\\ ', '\\"', "\\'");
$result =
parent::validate($uri, $config, $context);
if ($result ===
false) return false;
// escape necessary characters according to CSS spec
// except for the comma, none of these should appear in the
Documentation generated on Thu, 19 Jun 2008 18:50:29 -0400 by phpDocumentor 1.4.2