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