1Regexp::Common::URI::ftUps(e3r)Contributed Perl DocumentRaetgieoxnp::Common::URI::ftp(3)
2
3
4
6 Regexp::Common::URI::ftp -- Returns a pattern for FTP URIs.
7
9 use Regexp::Common qw /URI/;
10
11 while (<>) {
12 /$RE{URI}{FTP}/ and print "Contains an FTP URI.\n";
13 }
14
16 $RE{URI}{FTP}{-type}{-password};
17 Returns a regex for FTP URIs. Note: FTP URIs are not formally defined.
18 RFC 1738 defines FTP URLs, but parts of that RFC have been obsoleted by
19 RFC 2396. However, the differences between RFC 1738 and RFC 2396 are
20 such that they aren't applicable straightforwardly to FTP URIs.
21
22 There are two main problems:
23
24 Passwords.
25 RFC 1738 allowed an optional username and an optional password
26 (separated by a colon) in the FTP URL. Hence, colons were not
27 allowed in either the username or the password. RFC 2396 strongly
28 recommends passwords should not be used in URIs. It does allow for
29 userinfo instead. This userinfo part may contain colons, and hence
30 contain more than one colon. The regexp returned follows the RFC
31 2396 specification, unless the {-password} option is given; then
32 the regex allows for an optional username and password, separated
33 by a colon.
34
35 The ;type specifier.
36 RFC 1738 does not allow semi-colons in FTP path names, because a
37 semi-colon is a reserved character for FTP URIs. The semi-colon is
38 used to separate the path from the option type specifier. However,
39 in RFC 2396, paths consist of slash separated segments, and each
40 segment is a semi-colon separated group of parameters.
41 Straigthforward application of RFC 2396 would mean that a trailing
42 type specifier couldn't be distinguished from the last segment of
43 the path having a two parameters, the last one starting with type=.
44 Therefore we have opted to disallow a semi-colon in the path part
45 of an FTP URI.
46
47 Furthermore, RFC 1738 allows three values for the type specifier,
48 A, I and D (either upper case or lower case). However, the internet
49 draft about FTP URIs [DRAFT-FTP-URL] (which expired in May 1997)
50 notes the lack of consistent implementation of the D parameter and
51 drops D from the set of possible values. We follow this practise;
52 however, RFC 1738 behaviour can be archieved by using the -type =
53 "[ADIadi]"> parameter.
54
55 FTP URIs have the following syntax:
56
57 "ftp:" "//" [ userinfo "@" ] host [ ":" port ]
58 [ "/" path [ ";type=" value ]]
59
60 When using {-password}, we have the syntax:
61
62 "ftp:" "//" [ user [ ":" password ] "@" ] host [ ":" port ]
63 [ "/" path [ ";type=" value ]]
64
65 Under "{-keep}", the following are returned:
66
67 $1 The complete URI.
68
69 $2 The scheme.
70
71 $3 The userinfo, or if {-password} is used, the username.
72
73 $4 If {-password} is used, the password, else "undef".
74
75 $5 The hostname or IP address.
76
77 $6 The port number.
78
79 $7 The full path and type specification, including the leading slash.
80
81 $8 The full path and type specification, without the leading slash.
82
83 $9 The full path, without the type specification nor the leading
84 slash.
85
86 $10 The value of the type specification.
87
89 [DRAFT-URL-FTP]
90 Casey, James: A FTP URL Format. November 1996.
91
92 [RFC 1738]
93 Berners-Lee, Tim, Masinter, L., McCahill, M.: Uniform Resource
94 Locators (URL). December 1994.
95
96 [RFC 2396]
97 Berners-Lee, Tim, Fielding, R., and Masinter, L.: Uniform Resource
98 Identifiers (URI): Generic Syntax. August 1998.
99
101 Regexp::Common::URI for other supported URIs.
102
104 Damian Conway (damian@conway.org)
105
107 This package is maintained by Abigail (regexp-common@abigail.be).
108
110 Bound to be plenty.
111
113 This software is Copyright (c) 2001 - 2017, Damian Conway and Abigail.
114
115 This module is free software, and maybe used under any of the following
116 licenses:
117
118 1) The Perl Artistic License. See the file COPYRIGHT.AL.
119 2) The Perl Artistic License 2.0. See the file COPYRIGHT.AL2.
120 3) The BSD License. See the file COPYRIGHT.BSD.
121 4) The MIT License. See the file COPYRIGHT.MIT.
122
123
124
125perl v5.34.0 2021-07-22 Regexp::Common::URI::ftp(3)