diff options
author | Nicolas Lœuillet <nicolas@loeuillet.org> | 2014-02-21 15:57:10 +0100 |
---|---|---|
committer | Nicolas Lœuillet <nicolas@loeuillet.org> | 2014-02-21 15:57:10 +0100 |
commit | 99679d06884120c57f43b44e55e03595f1f87bed (patch) | |
tree | a3f2a1aa1afdaeca1386d0c6e8a75344fd2241fb /inc/3rdparty/htmlpurifier/HTMLPurifier/URIScheme/ftp.php | |
parent | 655214ab30ee84884dc408488b85586f36263fcb (diff) | |
parent | d3b47e94705e17b3ba3529cbb1dc6efe69c5d2b7 (diff) | |
download | wallabag-1.5.2.tar.gz wallabag-1.5.2.tar.zst wallabag-1.5.2.zip |
Merge pull request #481 from wallabag/dev1.5.2
1.5.2
Diffstat (limited to 'inc/3rdparty/htmlpurifier/HTMLPurifier/URIScheme/ftp.php')
-rw-r--r-- | inc/3rdparty/htmlpurifier/HTMLPurifier/URIScheme/ftp.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/inc/3rdparty/htmlpurifier/HTMLPurifier/URIScheme/ftp.php b/inc/3rdparty/htmlpurifier/HTMLPurifier/URIScheme/ftp.php new file mode 100644 index 00000000..8e7fb8c3 --- /dev/null +++ b/inc/3rdparty/htmlpurifier/HTMLPurifier/URIScheme/ftp.php | |||
@@ -0,0 +1,58 @@ | |||
1 | <?php | ||
2 | |||
3 | /** | ||
4 | * Validates ftp (File Transfer Protocol) URIs as defined by generic RFC 1738. | ||
5 | */ | ||
6 | class HTMLPurifier_URIScheme_ftp extends HTMLPurifier_URIScheme | ||
7 | { | ||
8 | /** | ||
9 | * @type int | ||
10 | */ | ||
11 | public $default_port = 21; | ||
12 | |||
13 | /** | ||
14 | * @type bool | ||
15 | */ | ||
16 | public $browsable = true; // usually | ||
17 | |||
18 | /** | ||
19 | * @type bool | ||
20 | */ | ||
21 | public $hierarchical = true; | ||
22 | |||
23 | /** | ||
24 | * @param HTMLPurifier_URI $uri | ||
25 | * @param HTMLPurifier_Config $config | ||
26 | * @param HTMLPurifier_Context $context | ||
27 | * @return bool | ||
28 | */ | ||
29 | public function doValidate(&$uri, $config, $context) | ||
30 | { | ||
31 | $uri->query = null; | ||
32 | |||
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"; | ||
47 | } | ||
48 | } else { | ||
49 | $uri->path .= '%3B' . $type; | ||
50 | } | ||
51 | $uri->path = str_replace(';', '%3B', $uri->path); | ||
52 | $uri->path .= $type_ret; | ||
53 | } | ||
54 | return true; | ||
55 | } | ||
56 | } | ||
57 | |||
58 | // vim: et sw=4 sts=4 | ||