PSR-2 reformatting PHPDoc corrections
[htmlpurifier.git] / library / HTMLPurifier / URIScheme / ftp.php
blob1eb43ee5c408da2a7df7cf753226f03b8ba3a9ed
1 <?php
3 /**
4 * Validates ftp (File Transfer Protocol) URIs as defined by generic RFC 1738.
5 */
6 class HTMLPurifier_URIScheme_ftp extends HTMLPurifier_URIScheme
8 /**
9 * @type int
11 public $default_port = 21;
13 /**
14 * @type bool
16 public $browsable = true; // usually
18 /**
19 * @type bool
21 public $hierarchical = true;
23 /**
24 * @param HTMLPurifier_URI $uri
25 * @param HTMLPurifier_Config $config
26 * @param HTMLPurifier_Context $context
27 * @return bool
29 public function doValidate(&$uri, $config, $context)
31 $uri->query = null;
33 // typecode check
34 $semicolon_pos = strrpos($uri->path, ';'); // reverse
35 if ($semicolon_pos !== false) {
36 $type = substr($uri->path, $semicolon_pos + 1); // no semicolon
37 $uri->path = substr($uri->path, 0, $semicolon_pos);
38 $type_ret = '';
39 if (strpos($type, '=') !== false) {
40 // figure out whether or not the declaration is correct
41 list($key, $typecode) = explode('=', $type, 2);
42 if ($key !== 'type') {
43 // invalid key, tack it back on encoded
44 $uri->path .= '%3B' . $type;
45 } elseif ($typecode === 'a' || $typecode === 'i' || $typecode === 'd') {
46 $type_ret = ";type=$typecode";
48 } else {
49 $uri->path .= '%3B' . $type;
51 $uri->path = str_replace(';', '%3B', $uri->path);
52 $uri->path .= $type_ret;
54 return true;
58 // vim: et sw=4 sts=4