ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
 @type HTMLPurifier_URIParser More...
 
 $embedsResource
 @type bool More...
 

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
bool$embeds_resourceDoes the URI here result in an extra HTTP request?

Definition at line 23 of file URI.php.

24 {
25 $this->parser = new HTMLPurifier_URIParser();
26 $this->embedsResource = (bool)$embeds_resource;
27 }
Parses a URI into the components and fragment identifier as specified by RFC 3986.
Definition: URIParser.php:8

Member Function Documentation

◆ make()

HTMLPurifier_AttrDef_URI::make (   $string)
Parameters
string$string
Returns
HTMLPurifier_AttrDef_URI

Reimplemented from HTMLPurifier_AttrDef.

Definition at line 33 of file URI.php.

34 {
35 $embeds = ($string === 'embedded');
36 return new HTMLPurifier_AttrDef_URI($embeds);
37 }
Validates a URI as defined by RFC 3986.
Definition: URI.php:8

◆ validate()

HTMLPurifier_AttrDef_URI::validate (   $uri,
  $config,
  $context 
)
Parameters
string$uri
HTMLPurifier_Config$config
HTMLPurifier_Context$context
Returns
bool|string

Reimplemented from HTMLPurifier_AttrDef.

Reimplemented in HTMLPurifier_AttrDef_CSS_URI.

Definition at line 45 of file URI.php.

46 {
47 if ($config->get('URI.Disable')) {
48 return false;
49 }
50
51 $uri = $this->parseCDATA($uri);
52
53 // parse the URI
54 $uri = $this->parser->parse($uri);
55 if ($uri === false) {
56 return false;
57 }
58
59 // add embedded flag to context for validators
60 $context->register('EmbeddedURI', $this->embedsResource);
61
62 $ok = false;
63 do {
64
65 // generic validation
66 $result = $uri->validate($config, $context);
67 if (!$result) {
68 break;
69 }
70
71 // chained filtering
72 $uri_def = $config->getDefinition('URI');
73 $result = $uri_def->filter($uri, $config, $context);
74 if (!$result) {
75 break;
76 }
77
78 // scheme-specific validation
79 $scheme_obj = $uri->getSchemeObj($config, $context);
80 if (!$scheme_obj) {
81 break;
82 }
83 if ($this->embedsResource && !$scheme_obj->browsable) {
84 break;
85 }
86 $result = $scheme_obj->validate($uri, $config, $context);
87 if (!$result) {
88 break;
89 }
90
91 // Post chained filtering
92 $result = $uri_def->postFilter($uri, $config, $context);
93 if (!$result) {
94 break;
95 }
96
97 // survived gauntlet
98 $ok = true;
99
100 } while (false);
101
102 $context->destroy('EmbeddedURI');
103 if (!$ok) {
104 return false;
105 }
106 // back to string
107 return $uri->toString();
108 }
$result
parseCDATA($string)
Convenience method that parses a string as if it were CDATA.
Definition: AttrDef.php:60

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

+ Here is the call graph for this function:

Field Documentation

◆ $embedsResource

HTMLPurifier_AttrDef_URI::$embedsResource
protected

@type bool

Definition at line 18 of file URI.php.

◆ $parser

HTMLPurifier_AttrDef_URI::$parser
protected

@type HTMLPurifier_URIParser

Definition at line 13 of file URI.php.


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