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