Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/htmlpurifier/HTMLPurifier/URIScheme.php
Go to the documentation of this file.
00001 <?php
00002 
00006 abstract class HTMLPurifier_URIScheme
00007 {
00008 
00014     public $default_port = null;
00015 
00020     public $browsable = false;
00021 
00026     public $hierarchical = false;
00027 
00033     public $may_omit_host = false;
00034 
00042     public abstract function doValidate(&$uri, $config, $context);
00043 
00052     public function validate(&$uri, $config, $context) {
00053         if ($this->default_port == $uri->port) $uri->port = null;
00054         // kludge: browsers do funny things when the scheme but not the
00055         // authority is set
00056         if (!$this->may_omit_host &&
00057             // if the scheme is present, a missing host is always in error
00058             (!is_null($uri->scheme) && ($uri->host === '' || is_null($uri->host))) ||
00059             // if the scheme is not present, a *blank* host is in error,
00060             // since this translates into '///path' which most browsers
00061             // interpret as being 'http://path'.
00062              (is_null($uri->scheme) && $uri->host === '')
00063         ) {
00064             do {
00065                 if (is_null($uri->scheme)) {
00066                     if (substr($uri->path, 0, 2) != '//') {
00067                         $uri->host = null;
00068                         break;
00069                     }
00070                     // URI is '////path', so we cannot nullify the
00071                     // host to preserve semantics.  Try expanding the
00072                     // hostname instead (fall through)
00073                 }
00074                 // first see if we can manually insert a hostname
00075                 $host = $config->get('URI.Host');
00076                 if (!is_null($host)) {
00077                     $uri->host = $host;
00078                 } else {
00079                     // we can't do anything sensible, reject the URL.
00080                     return false;
00081                 }
00082             } while (false);
00083         }
00084         return $this->doValidate($uri, $config, $context);
00085     }
00086 
00087 }
00088 
00089 // vim: et sw=4 sts=4
 All Data Structures Namespaces Files Functions Variables Enumerations