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
12 var $hierarchical = true;
14 function validate(&$uri, $config, &$context) {
15 parent
::validate($uri, $config, $context);
19 $semicolon_pos = strrpos($uri->path
, ';'); // reverse
20 if ($semicolon_pos !== false) {
21 $type = substr($uri->path
, $semicolon_pos +
1); // no semicolon
22 $uri->path
= substr($uri->path
, 0, $semicolon_pos);
24 if (strpos($type, '=') !== false) {
25 // figure out whether or not the declaration is correct
26 list($key, $typecode) = explode('=', $type, 2);
27 if ($key !== 'type') {
28 // invalid key, tack it back on encoded
29 $uri->path
.= '%3B' . $type;
30 } elseif ($typecode === 'a' ||
$typecode === 'i' ||
$typecode === 'd') {
31 $type_ret = ";type=$typecode";
34 $uri->path
.= '%3B' . $type;
36 $uri->path
= str_replace(';', '%3B', $uri->path
);
37 $uri->path
.= $type_ret;