ILIAS  release_4-4 Revision
HTMLPurifier_URIScheme Class Reference

Validator for the components of a URI for a specific scheme. More...

+ Inheritance diagram for HTMLPurifier_URIScheme:
+ Collaboration diagram for HTMLPurifier_URIScheme:

Public Member Functions

 doValidate (&$uri, $config, $context)
 Validates the components of a URI for a specific scheme. More...
 
 validate (&$uri, $config, $context)
 Public interface for validating components of a URI. More...
 

Data Fields

 $default_port = null
 Scheme's default port (integer). More...
 
 $browsable = false
 Whether or not URIs of this schem are locatable by a browser http and ftp are accessible, while mailto and news are not. More...
 
 $secure = false
 Whether or not data transmitted over this scheme is encrypted. More...
 
 $hierarchical = false
 Whether or not the URI always uses <hier_part>, resolves edge cases with making relative URIs absolute. More...
 
 $may_omit_host = false
 Whether or not the URI may omit a hostname when the scheme is explicitly specified, ala file:///path/to/file. More...
 

Detailed Description

Validator for the components of a URI for a specific scheme.

Definition at line 6 of file URIScheme.php.

Member Function Documentation

◆ doValidate()

HTMLPurifier_URIScheme::doValidate ( $uri,
  $config,
  $context 
)
abstract

Validates the components of a URI for a specific scheme.

Parameters
$uriReference to a HTMLPurifier_URI object
$configHTMLPurifier_Config object
$contextHTMLPurifier_Context object
Returns
Bool success or failure

Referenced by validate().

+ Here is the caller graph for this function:

◆ validate()

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

Public interface for validating components of a URI.

Performs a bunch of default actions. Don't overload this method.

Parameters
$uriReference to a HTMLPurifier_URI object
$configHTMLPurifier_Config object
$contextHTMLPurifier_Context object
Returns
Bool success or failure

Definition at line 58 of file URIScheme.php.

References doValidate().

58  {
59  if ($this->default_port == $uri->port) $uri->port = null;
60  // kludge: browsers do funny things when the scheme but not the
61  // authority is set
62  if (!$this->may_omit_host &&
63  // if the scheme is present, a missing host is always in error
64  (!is_null($uri->scheme) && ($uri->host === '' || is_null($uri->host))) ||
65  // if the scheme is not present, a *blank* host is in error,
66  // since this translates into '///path' which most browsers
67  // interpret as being 'http://path'.
68  (is_null($uri->scheme) && $uri->host === '')
69  ) {
70  do {
71  if (is_null($uri->scheme)) {
72  if (substr($uri->path, 0, 2) != '//') {
73  $uri->host = null;
74  break;
75  }
76  // URI is '////path', so we cannot nullify the
77  // host to preserve semantics. Try expanding the
78  // hostname instead (fall through)
79  }
80  // first see if we can manually insert a hostname
81  $host = $config->get('URI.Host');
82  if (!is_null($host)) {
83  $uri->host = $host;
84  } else {
85  // we can't do anything sensible, reject the URL.
86  return false;
87  }
88  } while (false);
89  }
90  return $this->doValidate($uri, $config, $context);
91  }
doValidate(&$uri, $config, $context)
Validates the components of a URI for a specific scheme.
+ Here is the call graph for this function:

Field Documentation

◆ $browsable

HTMLPurifier_URIScheme::$browsable = false

Whether or not URIs of this schem are locatable by a browser http and ftp are accessible, while mailto and news are not.

Definition at line 20 of file URIScheme.php.

◆ $default_port

HTMLPurifier_URIScheme::$default_port = null

Scheme's default port (integer).

If an explicit port number is specified that coincides with the default port, it will be elided.

Definition at line 14 of file URIScheme.php.

◆ $hierarchical

HTMLPurifier_URIScheme::$hierarchical = false

Whether or not the URI always uses <hier_part>, resolves edge cases with making relative URIs absolute.

Definition at line 32 of file URIScheme.php.

◆ $may_omit_host

HTMLPurifier_URIScheme::$may_omit_host = false

Whether or not the URI may omit a hostname when the scheme is explicitly specified, ala file:///path/to/file.

As of writing, 'file' is the only scheme that browsers support his properly.

Definition at line 39 of file URIScheme.php.

◆ $secure

HTMLPurifier_URIScheme::$secure = false

Whether or not data transmitted over this scheme is encrypted.

https is secure, http is not.

Definition at line 26 of file URIScheme.php.


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