ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
URIScheme.php
Go to the documentation of this file.
1 <?php
2 
6 abstract class HTMLPurifier_URIScheme
7 {
8 
14  public $default_port = null;
15 
20  public $browsable = false;
21 
26  public $secure = false;
27 
32  public $hierarchical = false;
33 
39  public $may_omit_host = false;
40 
48  public abstract function doValidate(&$uri, $config, $context);
49 
58  public function validate(&$uri, $config, $context) {
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  }
92 
93 }
94 
95 // vim: et sw=4 sts=4