HTMLPurifier 4.4.0
/home/ezyang/Dev/htmlpurifier/library/HTMLPurifier/URIScheme/ftp.php
Go to the documentation of this file.
00001 <?php
00002 
00006 class HTMLPurifier_URIScheme_ftp extends HTMLPurifier_URIScheme {
00007 
00008     public $default_port = 21;
00009     public $browsable = true; // usually
00010     public $hierarchical = true;
00011 
00012     public function doValidate(&$uri, $config, $context) {
00013         $uri->query    = null;
00014 
00015         // typecode check
00016         $semicolon_pos = strrpos($uri->path, ';'); // reverse
00017         if ($semicolon_pos !== false) {
00018             $type = substr($uri->path, $semicolon_pos + 1); // no semicolon
00019             $uri->path = substr($uri->path, 0, $semicolon_pos);
00020             $type_ret = '';
00021             if (strpos($type, '=') !== false) {
00022                 // figure out whether or not the declaration is correct
00023                 list($key, $typecode) = explode('=', $type, 2);
00024                 if ($key !== 'type') {
00025                     // invalid key, tack it back on encoded
00026                     $uri->path .= '%3B' . $type;
00027                 } elseif ($typecode === 'a' || $typecode === 'i' || $typecode === 'd') {
00028                     $type_ret = ";type=$typecode";
00029                 }
00030             } else {
00031                 $uri->path .= '%3B' . $type;
00032             }
00033             $uri->path = str_replace(';', '%3B', $uri->path);
00034             $uri->path .= $type_ret;
00035         }
00036 
00037         return true;
00038     }
00039 
00040 }
00041 
00042 // vim: et sw=4 sts=4