ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
URIScheme.php
Go to the documentation of this file.
1 <?php
2 
6 abstract class HTMLPurifier_URIScheme
7 {
8 
15  public $default_port = null;
16 
22  public $browsable = false;
23 
29  public $secure = false;
30 
36  public $hierarchical = false;
37 
44  public $may_omit_host = false;
45 
53  abstract public function doValidate(&$uri, $config, $context);
54 
63  public function validate(&$uri, $config, $context)
64  {
65  if ($this->default_port == $uri->port) {
66  $uri->port = null;
67  }
68  // kludge: browsers do funny things when the scheme but not the
69  // authority is set
70  if (!$this->may_omit_host &&
71  // if the scheme is present, a missing host is always in error
72  (!is_null($uri->scheme) && ($uri->host === '' || is_null($uri->host))) ||
73  // if the scheme is not present, a *blank* host is in error,
74  // since this translates into '///path' which most browsers
75  // interpret as being 'http://path'.
76  (is_null($uri->scheme) && $uri->host === '')
77  ) {
78  do {
79  if (is_null($uri->scheme)) {
80  if (substr($uri->path, 0, 2) != '//') {
81  $uri->host = null;
82  break;
83  }
84  // URI is '////path', so we cannot nullify the
85  // host to preserve semantics. Try expanding the
86  // hostname instead (fall through)
87  }
88  // first see if we can manually insert a hostname
89  $host = $config->get('URI.Host');
90  if (!is_null($host)) {
91  $uri->host = $host;
92  } else {
93  // we can't do anything sensible, reject the URL.
94  return false;
95  }
96  } while (false);
97  }
98  return $this->doValidate($uri, $config, $context);
99  }
100 }
101 
102 // vim: et sw=4 sts=4
$may_omit_host
Whether or not the URI may omit a hostname when the scheme is explicitly specified, ala file:///path/to/file.
Definition: URIScheme.php:44
validate(&$uri, $config, $context)
Public interface for validating components of a URI.
Definition: URIScheme.php:63
$browsable
Whether or not URIs of this scheme are locatable by a browser http and ftp are accessible, while mailto and news are not.
Definition: URIScheme.php:22
$default_port
Scheme&#39;s default port (integer).
Definition: URIScheme.php:15
$secure
Whether or not data transmitted over this scheme is encrypted.
Definition: URIScheme.php:29
$hierarchical
Whether or not the URI always uses <hier_part>, resolves edge cases with making relative URIs absolut...
Definition: URIScheme.php:36
doValidate(&$uri, $config, $context)
Validates the components of a URI for a specific scheme.
Validator for the components of a URI for a specific scheme.
Definition: URIScheme.php:6