/usr/share/perl5/Regexp/Common/URI/ftp.pm is in libregexp-common-perl 2016060801-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | package Regexp::Common::URI::ftp;
use Regexp::Common qw /pattern clean no_defaults/;
use Regexp::Common::URI qw /register_uri/;
use Regexp::Common::URI::RFC2396 qw /$host $port $ftp_segments $userinfo
$userinfo_no_colon/;
use strict;
use warnings;
use vars qw /$VERSION/;
$VERSION = '2016060801';
my $ftp_uri = "(?k:(?k:ftp)://(?:(?k:$userinfo)(?k:)\@)?(?k:$host)" .
"(?::(?k:$port))?(?k:/(?k:(?k:$ftp_segments)" .
"(?:;type=(?k:[AIai]))?))?)";
my $ftp_uri_password =
"(?k:(?k:ftp)://(?:(?k:$userinfo_no_colon)" .
"(?::(?k:$userinfo_no_colon))?\@)?(?k:$host)" .
"(?::(?k:$port))?(?k:/(?k:(?k:$ftp_segments)" .
"(?:;type=(?k:[AIai]))?))?)";
register_uri FTP => $ftp_uri;
pattern name => [qw (URI FTP), "-type=[AIai]", "-password="],
create => sub {
my $uri = exists $_ [1] -> {-password} &&
!defined $_ [1] -> {-password} ? $ftp_uri_password
: $ftp_uri;
my $type = $_ [1] -> {-type};
$uri =~ s/\[AIai\]/$type/;
$uri;
}
;
1;
__END__
=pod
=head1 NAME
Regexp::Common::URI::ftp -- Returns a pattern for FTP URIs.
=head1 SYNOPSIS
use Regexp::Common qw /URI/;
while (<>) {
/$RE{URI}{FTP}/ and print "Contains an FTP URI.\n";
}
=head1 DESCRIPTION
=head2 $RE{URI}{FTP}{-type}{-password};
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:
=over 4
=item Passwords.
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 I<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 I<{-password}>
option is given; then the regex allows for an optional username and
password, separated by a colon.
=item The ;type specifier.
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 I<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 I<type> specifier couldn't be distinguished
from the last segment of the path having a two parameters, the last one
starting with I<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, I<A>,
I<I> and I<D> (either upper case or lower case). However, the internet
draft about FTP URIs B<[DRAFT-FTP-URL]> (which expired in May 1997) notes
the lack of consistent implementation of the I<D> parameter and drops I<D>
from the set of possible values. We follow this practise; however, RFC 1738
behaviour can be archieved by using the I<-type => "[ADIadi]"> parameter.
=back
FTP URIs have the following syntax:
"ftp:" "//" [ userinfo "@" ] host [ ":" port ]
[ "/" path [ ";type=" value ]]
When using I<{-password}>, we have the syntax:
"ftp:" "//" [ user [ ":" password ] "@" ] host [ ":" port ]
[ "/" path [ ";type=" value ]]
Under C<{-keep}>, the following are returned:
=over 4
=item $1
The complete URI.
=item $2
The scheme.
=item $3
The userinfo, or if I<{-password}> is used, the username.
=item $4
If I<{-password}> is used, the password, else C<undef>.
=item $5
The hostname or IP address.
=item $6
The port number.
=item $7
The full path and type specification, including the leading slash.
=item $8
The full path and type specification, without the leading slash.
=item $9
The full path, without the type specification nor the leading slash.
=item $10
The value of the type specification.
=back
=head1 REFERENCES
=over 4
=item B<[DRAFT-URL-FTP]>
Casey, James: I<A FTP URL Format>. November 1996.
=item B<[RFC 1738]>
Berners-Lee, Tim, Masinter, L., McCahill, M.: I<Uniform Resource
Locators (URL)>. December 1994.
=item B<[RFC 2396]>
Berners-Lee, Tim, Fielding, R., and Masinter, L.: I<Uniform Resource
Identifiers (URI): Generic Syntax>. August 1998.
=back
=head1 SEE ALSO
L<Regexp::Common::URI> for other supported URIs.
=head1 AUTHOR
Damian Conway (damian@conway.org)
=head1 MAINTENANCE
This package is maintained by Abigail S<(I<regexp-common@abigail.be>)>.
=head1 BUGS AND IRRITATIONS
Bound to be plenty.
=head1 LICENSE and COPYRIGHT
This software is Copyright (c) 2001 - 2016, Damian Conway and Abigail.
This module is free software, and maybe used under any of the following
licenses:
1) The Perl Artistic License. See the file COPYRIGHT.AL.
2) The Perl Artistic License 2.0. See the file COPYRIGHT.AL2.
3) The BSD License. See the file COPYRIGHT.BSD.
4) The MIT License. See the file COPYRIGHT.MIT.
=cut
|