]> git.wh0rd.org - tt-rss.git/blame - lib/htmlpurifier/library/HTMLPurifier/URIScheme/ftp.php
update HTMLPurifier; enable embedded flash video in articles
[tt-rss.git] / lib / htmlpurifier / library / HTMLPurifier / URIScheme / ftp.php
CommitLineData
f45a286b
AD
1<?php
2
3/**
4 * Validates ftp (File Transfer Protocol) URIs as defined by generic RFC 1738.
5 */
6class HTMLPurifier_URIScheme_ftp extends HTMLPurifier_URIScheme {
7
8 public $default_port = 21;
9 public $browsable = true; // usually
10 public $hierarchical = true;
11
f4f0f80d 12 public function doValidate(&$uri, $config, $context) {
f45a286b
AD
13 $uri->query = null;
14
15 // typecode check
16 $semicolon_pos = strrpos($uri->path, ';'); // reverse
17 if ($semicolon_pos !== false) {
18 $type = substr($uri->path, $semicolon_pos + 1); // no semicolon
19 $uri->path = substr($uri->path, 0, $semicolon_pos);
20 $type_ret = '';
21 if (strpos($type, '=') !== false) {
22 // figure out whether or not the declaration is correct
23 list($key, $typecode) = explode('=', $type, 2);
24 if ($key !== 'type') {
25 // invalid key, tack it back on encoded
26 $uri->path .= '%3B' . $type;
27 } elseif ($typecode === 'a' || $typecode === 'i' || $typecode === 'd') {
28 $type_ret = ";type=$typecode";
29 }
30 } else {
31 $uri->path .= '%3B' . $type;
32 }
33 $uri->path = str_replace(';', '%3B', $uri->path);
34 $uri->path .= $type_ret;
35 }
36
37 return true;
38 }
39
40}
41
42// vim: et sw=4 sts=4