ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
HTMLPurifier_AttrDef_URI Class Reference

Validates a URI as defined by RFC 3986. More...

+ Inheritance diagram for HTMLPurifier_AttrDef_URI:
+ Collaboration diagram for HTMLPurifier_AttrDef_URI:

Public Member Functions

 __construct ($embeds_resource=false)
 make ($string)
 Factory method for creating this class from a string.
 validate ($uri, $config, $context)
 Validates and cleans passed string according to a definition.
- Public Member Functions inherited from HTMLPurifier_AttrDef
 parseCDATA ($string)
 Convenience method that parses a string as if it were CDATA.

Protected Attributes

 $parser
 $embedsResource

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.

Detailed Description

Validates a URI as defined by RFC 3986.

Note
Scheme-specific mechanics deferred to HTMLPurifier_URIScheme

Definition at line 7 of file URI.php.

Constructor & Destructor Documentation

HTMLPurifier_AttrDef_URI::__construct (   $embeds_resource = false)
Parameters
$embeds_resource_resourceDoes the URI here result in an extra HTTP request?

Definition at line 16 of file URI.php.

{
$this->parser = new HTMLPurifier_URIParser();
$this->embedsResource = (bool) $embeds_resource;
}

Member Function Documentation

HTMLPurifier_AttrDef_URI::make (   $string)

Factory method for creating this class from a string.

Parameters
$stringString construction info
Returns
Created AttrDef object corresponding to $string

Reimplemented from HTMLPurifier_AttrDef.

Definition at line 21 of file URI.php.

{
$embeds = (bool) $string;
return new HTMLPurifier_AttrDef_URI($embeds);
}
HTMLPurifier_AttrDef_URI::validate (   $string,
  $config,
  $context 
)

Validates and cleans passed string according to a definition.

Parameters
$stringString to be validated and cleaned.
$configMandatory HTMLPurifier_Config object.
$contextMandatory HTMLPurifier_AttrContext object.

Reimplemented from HTMLPurifier_AttrDef.

Reimplemented in HTMLPurifier_AttrDef_CSS_URI.

Definition at line 26 of file URI.php.

References $config, $ok, and HTMLPurifier_AttrDef\parseCDATA().

{
if ($config->get('URI.Disable')) return false;
$uri = $this->parseCDATA($uri);
// parse the URI
$uri = $this->parser->parse($uri);
if ($uri === false) return false;
// add embedded flag to context for validators
$context->register('EmbeddedURI', $this->embedsResource);
$ok = false;
do {
// generic validation
$result = $uri->validate($config, $context);
if (!$result) break;
// chained filtering
$uri_def = $config->getDefinition('URI');
$result = $uri_def->filter($uri, $config, $context);
if (!$result) break;
// scheme-specific validation
$scheme_obj = $uri->getSchemeObj($config, $context);
if (!$scheme_obj) break;
if ($this->embedsResource && !$scheme_obj->browsable) break;
$result = $scheme_obj->validate($uri, $config, $context);
if (!$result) break;
// Post chained filtering
$result = $uri_def->postFilter($uri, $config, $context);
if (!$result) break;
// survived gauntlet
$ok = true;
} while (false);
$context->destroy('EmbeddedURI');
if (!$ok) return false;
// back to string
return $uri->toString();
}

+ Here is the call graph for this function:

Field Documentation

HTMLPurifier_AttrDef_URI::$embedsResource
protected

Definition at line 11 of file URI.php.

HTMLPurifier_AttrDef_URI::$parser
protected

Definition at line 10 of file URI.php.


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