ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules 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)
 
 validate ($uri, $config, $context)
 
- Public Member Functions inherited from HTMLPurifier_AttrDef
 validate ($string, $config, $context)
 Validates and cleans passed string according to a definition. More...
 
 parseCDATA ($string)
 Convenience method that parses a string as if it were CDATA. More...
 
 make ($string)
 Factory method for creating this class from a string. More...
 

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. More...
 
 $required = false
 Tells us whether or not an HTML attribute is required. More...
 
- Protected Member Functions inherited from HTMLPurifier_AttrDef
 mungeRgb ($string)
 Removes spaces from rgb(0, 0, 0) so that shorthand CSS properties work properly. More...
 
 expandCSSEscape ($string)
 Parses a possibly escaped CSS string and returns the "pure" version of it. More...
 

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

◆ __construct()

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.

16  {
17  $this->parser = new HTMLPurifier_URIParser();
18  $this->embedsResource = (bool) $embeds_resource;
19  }
Parses a URI into the components and fragment identifier as specified by RFC 3986.
Definition: URIParser.php:7

Member Function Documentation

◆ make()

HTMLPurifier_AttrDef_URI::make (   $string)

Definition at line 21 of file URI.php.

21  {
22  $embeds = ($string === 'embedded');
23  return new HTMLPurifier_AttrDef_URI($embeds);
24  }
Validates a URI as defined by RFC 3986.
Definition: URI.php:7

◆ validate()

HTMLPurifier_AttrDef_URI::validate (   $uri,
  $config,
  $context 
)

Definition at line 26 of file URI.php.

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

26  {
27 
28  if ($config->get('URI.Disable')) return false;
29 
30  $uri = $this->parseCDATA($uri);
31 
32  // parse the URI
33  $uri = $this->parser->parse($uri);
34  if ($uri === false) return false;
35 
36  // add embedded flag to context for validators
37  $context->register('EmbeddedURI', $this->embedsResource);
38 
39  $ok = false;
40  do {
41 
42  // generic validation
43  $result = $uri->validate($config, $context);
44  if (!$result) break;
45 
46  // chained filtering
47  $uri_def = $config->getDefinition('URI');
48  $result = $uri_def->filter($uri, $config, $context);
49  if (!$result) break;
50 
51  // scheme-specific validation
52  $scheme_obj = $uri->getSchemeObj($config, $context);
53  if (!$scheme_obj) break;
54  if ($this->embedsResource && !$scheme_obj->browsable) break;
55  $result = $scheme_obj->validate($uri, $config, $context);
56  if (!$result) break;
57 
58  // Post chained filtering
59  $result = $uri_def->postFilter($uri, $config, $context);
60  if (!$result) break;
61 
62  // survived gauntlet
63  $ok = true;
64 
65  } while (false);
66 
67  $context->destroy('EmbeddedURI');
68  if (!$ok) return false;
69 
70  // back to string
71  return $uri->toString();
72 
73  }
$result
parseCDATA($string)
Convenience method that parses a string as if it were CDATA.
Definition: AttrDef.php:58
+ Here is the call graph for this function:

Field Documentation

◆ $embedsResource

HTMLPurifier_AttrDef_URI::$embedsResource
protected

Definition at line 11 of file URI.php.

◆ $parser

HTMLPurifier_AttrDef_URI::$parser
protected

Definition at line 10 of file URI.php.


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