Validates a URI in CSS syntax, which uses url('http://example.com')
More...
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.
Definition at line 12 of file URI.php.
◆ __construct()
HTMLPurifier_AttrDef_CSS_URI::__construct |
( |
| ) |
|
Definition at line 15 of file URI.php.
17 parent::__construct(
true);
◆ validate()
HTMLPurifier_AttrDef_CSS_URI::validate |
( |
|
$uri_string, |
|
|
|
$config, |
|
|
|
$context |
|
) |
| |
- Parameters
-
- Returns
- bool|string
Definition at line 26 of file URI.php.
References $result, HTMLPurifier_AttrDef\expandCSSEscape(), and HTMLPurifier_AttrDef\parseCDATA().
32 if (strpos($uri_string,
'url(') !== 0) {
35 $uri_string = substr($uri_string, 4);
36 $new_length = strlen($uri_string) - 1;
37 if ($uri_string[$new_length] !=
')') {
40 $uri = trim(substr($uri_string, 0, $new_length));
42 if (!empty($uri) && ($uri[0] ==
"'" || $uri[0] ==
'"')) {
44 $new_length = strlen($uri) - 1;
45 if ($uri[$new_length] !== $quote) {
48 $uri = substr($uri, 1, $new_length - 1);
53 $result = parent::validate($uri, $config, $context);
60 $result = str_replace(array(
'"',
"\\",
"\n",
"\x0c",
"\r"),
"",
$result);
64 $result = str_replace(array(
'(',
')',
"'"), array(
'%28',
'%29',
'%27'),
$result);
70 return "url(\"$result\")";
parseCDATA($string)
Convenience method that parses a string as if it were CDATA.
expandCSSEscape($string)
Parses a possibly escaped CSS string and returns the "pure" version of it.
The documentation for this class was generated from the following file:
- Services/Html/HtmlPurifier/library/HTMLPurifier/AttrDef/CSS/URI.php