ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
HTMLPurifier_AttrDef_CSS_URI Class Reference

Validates a URI in CSS syntax, which uses url('http://example.com') More...

+ Inheritance diagram for HTMLPurifier_AttrDef_CSS_URI:
+ Collaboration diagram for HTMLPurifier_AttrDef_CSS_URI:

Public Member Functions

 __construct ()
 validate ($uri_string, $config, $context)
- Public Member Functions inherited from HTMLPurifier_AttrDef_URI
 __construct ($embeds_resource=false)
 make ($string)
- Public Member Functions inherited from HTMLPurifier_AttrDef
 parseCDATA ($string)
 Convenience method that parses a string as if it were CDATA.

Additional Inherited Members

- Data Fields inherited from HTMLPurifier_AttrDef
 $minimized = false
 Tells us whether or not an HTML attribute is minimized.
 $required = false
 Tells us whether or not an HTML attribute is required.
- Protected Member Functions inherited from HTMLPurifier_AttrDef
 mungeRgb ($string)
 Removes spaces from rgb(0, 0, 0) so that shorthand CSS properties work properly.
 expandCSSEscape ($string)
 Parses a possibly escaped CSS string and returns the "pure" version of it.
- Protected Attributes inherited from HTMLPurifier_AttrDef_URI
 $parser
 HTMLPurifier_URIParser
 $embedsResource
 bool

Detailed Description

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.

Constructor & Destructor Documentation

HTMLPurifier_AttrDef_CSS_URI::__construct ( )

Definition at line 15 of file URI.php.

{
parent::__construct(true); // always embedded
}

Member Function Documentation

HTMLPurifier_AttrDef_CSS_URI::validate (   $uri_string,
  $config,
  $context 
)
Parameters
string$uri_string
HTMLPurifier_Config$config
HTMLPurifier_Context$context
Returns
bool|string

Reimplemented from HTMLPurifier_AttrDef_URI.

Definition at line 26 of file URI.php.

References $result, HTMLPurifier_AttrDef\expandCSSEscape(), and HTMLPurifier_AttrDef\parseCDATA().

{
// parse the URI out of the string and then pass it onto
// the parent object
$uri_string = $this->parseCDATA($uri_string);
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;
}
$uri = trim(substr($uri_string, 0, $new_length));
if (!empty($uri) && ($uri[0] == "'" || $uri[0] == '"')) {
$quote = $uri[0];
$new_length = strlen($uri) - 1;
if ($uri[$new_length] !== $quote) {
return false;
}
$uri = substr($uri, 1, $new_length - 1);
}
$uri = $this->expandCSSEscape($uri);
$result = parent::validate($uri, $config, $context);
if ($result === false) {
return false;
}
// extra sanity check; should have been done by URI
$result = str_replace(array('"', "\\", "\n", "\x0c", "\r"), "", $result);
// suspicious characters are ()'; we're going to percent encode
// them for safety.
$result = str_replace(array('(', ')', "'"), array('%28', '%29', '%27'), $result);
// there's an extra bug where ampersands lose their escaping on
// an innerHTML cycle, so a very unlucky query parameter could
// then change the meaning of the URL. Unfortunately, there's
// not much we can do about that...
return "url(\"$result\")";
}

+ Here is the call graph for this function:


The documentation for this class was generated from the following file: