3 require_once 'HTMLPurifier/URIScheme.php';
6 * Validates ftp (File Transfer Protocol) URIs as defined by generic RFC 1738.
8 class HTMLPurifier_URIScheme_ftp
extends HTMLPurifier_URIScheme
{
10 var $default_port = 21;
11 var $browsable = true; // usually
13 function validateComponents(
14 $userinfo, $host, $port, $path, $query, $config, &$context
16 list($userinfo, $host, $port, $path, $query) =
17 parent
::validateComponents(
18 $userinfo, $host, $port, $path, $query, $config, $context );
19 $semicolon_pos = strrpos($path, ';'); // reverse
20 if ($semicolon_pos !== false) {
22 $type = substr($path, $semicolon_pos +
1); // no semicolon
23 $path = substr($path, 0, $semicolon_pos);
25 if (strpos($type, '=') !== false) {
26 // figure out whether or not the declaration is correct
27 list($key, $typecode) = explode('=', $type, 2);
28 if ($key !== 'type') {
29 // invalid key, tack it back on encoded
30 $path .= '%3B' . $type;
31 } elseif ($typecode === 'a' ||
$typecode === 'i' ||
$typecode === 'd') {
32 $type_ret = ";type=$typecode";
35 $path .= '%3B' . $type;
37 $path = str_replace(';', '%3B', $path);
40 return array($userinfo, $host, $port, $path, null);