|
|
Regexp::Common::URI::ftp -- Returns a pattern for FTP URIs.
use Regexp::Common qw /URI/;
while (<>) { /$RE{URI}{FTP}/ and print "Contains an FTP URI.\n"; }
Returns a regex for FTP URIs. Note: FTP URIs are not formally defined. RFC 1738 defines FTP URLs, but parts of that RFC have been obsoleted by RFC 2396. However, the differences between RFC 1738 and RFC 2396 are such that they aren't applicable straightforwardly to FTP URIs.
There are two main problems:
RFC 1738 allowed an optional username and an optional password (separated by a colon) in the FTP URL. Hence, colons were not allowed in either the username or the password. RFC 2396 strongly recommends passwords should not be used in URIs. It does allow for userinfo instead. This userinfo part may contain colons, and hence contain more than one colon. The regexp returned follows the RFC 2396 specification, unless the {-password} option is given; then the regex allows for an optional username and password, separated by a colon.
RFC 1738 does not allow semi-colons in FTP path names, because a semi-colon is a reserved character for FTP URIs. The semi-colon is used to separate the path from the option type specifier. However, in RFC 2396, paths consist of slash separated segments, and each segment is a semi-colon separated group of parameters. Straigthforward application of RFC 2396 would mean that a trailing type specifier couldn't be distinguished from the last segment of the path having a two parameters, the last one starting with type=. Therefore we have opted to disallow a semi-colon in the path part of an FTP URI.
Furthermore, RFC 1738 allows three values for the type specifier, A, I and D (either upper case or lower case). However, the internet draft about FTP URIs [DRAFT-FTP-URL] (which expired in May 1997) notes the lack of consistent implementation of the D parameter and drops D from the set of possible values. We follow this practise; however, RFC 1738 behaviour can be archieved by using the -type = ``[ADIadi]''> parameter.
FTP URIs have the following syntax:
"ftp:" "//" [ userinfo "@" ] host [ ":" port ] [ "/" path [ ";type=" value ]]
When using {-password}, we have the syntax:
"ftp:" "//" [ user [ ":" password ] "@" ] host [ ":" port ] [ "/" path [ ";type=" value ]]
Under {-keep}
, the following are returned:
The complete URI.
The scheme.
The userinfo, or if {-password} is used, the username.
If {-password} is used, the password, else undef
.
The hostname or IP address.
The port number.
The full path and type specification, including the leading slash.
The full path and type specification, without the leading slash.
The full path, without the type specification nor the leading slash.
The value of the type specification.
Casey, James: A FTP URL Format. November 1996.
Berners-Lee, Tim, Masinter, L., McCahill, M.: Uniform Resource Locators (URL). December 1994.
Berners-Lee, Tim, Fielding, R., and Masinter, L.: Uniform Resource Identifiers (URI): Generic Syntax. August 1998.
$Log: ftp.pm,v $ Revision 2.101 2004/06/09 21:42:48 abigail POD nits
Revision 2.100 2003/02/10 21:06:40 abigail ftp URI
the Regexp::Common::URI manpage for other supported URIs.
Damian Conway (damian@conway.org)
This package is maintained by Abigail (regexp-common@abigail.nl).
Bound to be plenty.
Copyright (c) 2001 - 2003, Damian Conway. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the terms of the Perl Artistic License (see http://www.perl.com/perl/misc/Artistic.html)