Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

802 lines
23 KiB

  1. package URI; # $Id: URI.pm,v 1.29 1999/08/02 22:45:52 gisle Exp $
  2. use strict;
  3. use vars qw($VERSION);
  4. $VERSION = "1.04";
  5. use vars qw($ABS_REMOTE_LEADING_DOTS $ABS_ALLOW_RELATIVE_SCHEME);
  6. my %implements; # mapping from scheme to implementor class
  7. # Some "official" character classes
  8. use vars qw($reserved $mark $unreserved $uric $scheme_re);
  9. $reserved = q(;/?:@&=+$,);
  10. $mark = q(-_.!~*'()); #'; emacs
  11. $unreserved = "A-Za-z0-9\Q$mark\E";
  12. $uric = quotemeta($reserved) . $unreserved . "%";
  13. $scheme_re = '[a-zA-Z][a-zA-Z0-9.+\-]*';
  14. use Carp ();
  15. use URI::Escape ();
  16. use overload ('""' => sub { ${$_[0]} },
  17. '==' => sub { overload::StrVal($_[0]) eq
  18. overload::StrVal($_[1])
  19. },
  20. fallback => 1,
  21. );
  22. sub new
  23. {
  24. my($class, $uri, $scheme) = @_;
  25. $uri = defined ($uri) ? "$uri" : ""; # stringify
  26. # Get rid of potential wrapping
  27. $uri =~ s/^<(?:URL:)?(.*)>$/$1/; #
  28. $uri =~ s/^"(.*)"$/$1/;
  29. $uri =~ s/^\s+//;
  30. $uri =~ s/\s+$//;
  31. my $impclass;
  32. if ($uri =~ m/^($scheme_re):/so) {
  33. $scheme = $1;
  34. } else {
  35. if (($impclass = ref($scheme))) {
  36. $scheme = $scheme->scheme;
  37. } elsif ($scheme && $scheme =~ m/^($scheme_re)(?::|$)/o) {
  38. $scheme = $1;
  39. }
  40. }
  41. $impclass ||= implementor($scheme) ||
  42. do {
  43. require URI::_foreign;
  44. $impclass = 'URI::_foreign';
  45. };
  46. return $impclass->_init($uri, $scheme);
  47. }
  48. sub new_abs
  49. {
  50. my($class, $uri, $base) = @_;
  51. $uri = $class->new($uri, $base);
  52. $uri->abs($base);
  53. }
  54. sub _init
  55. {
  56. my $class = shift;
  57. my($str, $scheme) = @_;
  58. $str =~ s/([^$uric\#])/$URI::Escape::escapes{$1}/go;
  59. $str = "$scheme:$str" unless $str =~ /^$scheme_re:/o ||
  60. $class->_no_scheme_ok;
  61. my $self = bless \$str, $class;
  62. $self;
  63. }
  64. sub implementor
  65. {
  66. my($scheme, $impclass) = @_;
  67. unless ($scheme) {
  68. require URI::_generic;
  69. return "URI::_generic";
  70. }
  71. $scheme = lc($scheme);
  72. if ($impclass) {
  73. # Set the implementor class for a given scheme
  74. my $old = $implements{$scheme};
  75. $impclass->_init_implementor($scheme);
  76. $implements{$scheme} = $impclass;
  77. return $old;
  78. }
  79. my $ic = $implements{$scheme};
  80. return $ic if $ic;
  81. # scheme not yet known, look for internal or
  82. # preloaded (with 'use') implementation
  83. $ic = "URI::$scheme"; # default location
  84. # turn scheme into a valid perl identifier by a simple tranformation...
  85. $ic =~ s/\+/_P/g;
  86. $ic =~ s/\./_O/g;
  87. $ic =~ s/\-/_/g;
  88. no strict 'refs';
  89. # check we actually have one for the scheme:
  90. unless (@{"${ic}::ISA"}) {
  91. # Try to load it
  92. eval "require $ic";
  93. die $@ if $@ && $@ !~ /Can\'t locate.*in \@INC/;
  94. return unless @{"${ic}::ISA"};
  95. }
  96. $ic->_init_implementor($scheme);
  97. $implements{$scheme} = $ic;
  98. $ic;
  99. }
  100. sub _init_implementor
  101. {
  102. my($class, $scheme) = @_;
  103. # Remember that one implementor class may actually
  104. # serve to implement several URI schemes.
  105. }
  106. sub clone
  107. {
  108. my $self = shift;
  109. my $other = $$self;
  110. bless \$other, ref $self;
  111. }
  112. sub _no_scheme_ok { 0 }
  113. sub _scheme
  114. {
  115. my $self = shift;
  116. unless (@_) {
  117. return unless $$self =~ /^($scheme_re):/o;
  118. return $1;
  119. }
  120. my $old;
  121. my $new = shift;
  122. if (defined($new) && length($new)) {
  123. Carp::croak("Bad scheme '$new'") unless $new =~ /^$scheme_re$/o;
  124. $old = $1 if $$self =~ s/^($scheme_re)://o;
  125. my $newself = URI->new("$new:$$self");
  126. $$self = $$newself;
  127. bless $self, ref($newself);
  128. } else {
  129. if ($self->_no_scheme_ok) {
  130. $old = $1 if $$self =~ s/^($scheme_re)://o;
  131. Carp::carp("Oops, opaque part now look like scheme")
  132. if $^W && $$self =~ m/^$scheme_re:/o
  133. } else {
  134. $old = $1 if $$self =~ m/^($scheme_re):/o;
  135. }
  136. }
  137. return $old;
  138. }
  139. sub scheme
  140. {
  141. my $scheme = shift->_scheme(@_);
  142. return unless defined $scheme;
  143. lc($scheme);
  144. }
  145. sub opaque
  146. {
  147. my $self = shift;
  148. unless (@_) {
  149. $$self =~ /^(?:$scheme_re:)?([^\#]*)/o or die;
  150. return $1;
  151. }
  152. $$self =~ /^($scheme_re:)? # optional scheme
  153. ([^\#]*) # opaque
  154. (\#.*)? # optional fragment
  155. $/sx or die;
  156. my $old_scheme = $1;
  157. my $old_opaque = $2;
  158. my $old_frag = $3;
  159. my $new_opaque = shift;
  160. $new_opaque = "" unless defined $new_opaque;
  161. $new_opaque =~ s/([^$uric])/$URI::Escape::escapes{$1}/go;
  162. $$self = defined($old_scheme) ? $old_scheme : "";
  163. $$self .= $new_opaque;
  164. $$self .= $old_frag if defined $old_frag;
  165. $old_opaque;
  166. }
  167. *path = \&opaque; # alias
  168. sub fragment
  169. {
  170. my $self = shift;
  171. unless (@_) {
  172. return unless $$self =~ /\#(.*)/s;
  173. return $1;
  174. }
  175. my $old;
  176. $old = $1 if $$self =~ s/\#(.*)//s;
  177. my $new_frag = shift;
  178. if (defined $new_frag) {
  179. $new_frag =~ s/([^$uric])/$URI::Escape::escapes{$1}/go;
  180. $$self .= "#$new_frag";
  181. }
  182. $old;
  183. }
  184. sub as_string
  185. {
  186. my $self = shift;
  187. $$self;
  188. }
  189. sub canonical
  190. {
  191. my $self = shift;
  192. # Make sure scheme is lowercased
  193. my $scheme = $self->_scheme || "";
  194. my $uc_scheme = $scheme =~ /[A-Z]/;
  195. my $lc_esc = $$self =~ /%(?:[a-f][a-fA-F0-9]|[A-F0-9][a-f])/;
  196. if ($uc_scheme || $lc_esc) {
  197. my $other = $self->clone;
  198. $other->_scheme(lc $scheme) if $uc_scheme;
  199. $$other =~ s/(%(?:[a-f][a-fA-F0-9]|[A-F0-9][a-f]))/uc($1)/ge
  200. if $lc_esc;
  201. return $other;
  202. }
  203. $self;
  204. }
  205. # Compare two URIs, subclasses will provide a more correct implementation
  206. sub eq {
  207. my($self, $other) = @_;
  208. $self = URI->new($self, $other) unless ref $self;
  209. $other = URI->new($other, $self) unless ref $other;
  210. ref($self) eq ref($other) && # same class
  211. $self->canonical->as_string eq $other->canonical->as_string;
  212. }
  213. # generic-URI transformation methods
  214. sub abs { $_[0]; }
  215. sub rel { $_[0]; }
  216. 1;
  217. __END__
  218. =head1 NAME
  219. URI - Uniform Resource Identifiers (absolute and relative)
  220. =head1 SYNOPSIS
  221. $u1 = URI->new("http://www.perl.com");
  222. $u2 = URI->new("foo", "http");
  223. $u3 = $u2->abs($u1);
  224. $u4 = $u3->clone;
  225. $u5 = URI->new("HTTP://WWW.perl.com:80")->canonical;
  226. $str = $u->as_string;
  227. $str = "$u";
  228. $scheme = $u->scheme;
  229. $opaque = $u->opaque;
  230. $path = $u->path;
  231. $frag = $u->fragment;
  232. $u->scheme("ftp");
  233. $u->host("ftp.perl.com");
  234. $u->path("cpan/");
  235. =head1 DESCRIPTION
  236. This module implements the C<URI> class. Objects of this class
  237. represent "Uniform Resource Identifier references" as specified in RFC
  238. 2396.
  239. A Uniform Resource Identifier is a compact string of characters for
  240. identifying an abstract or physical resource. A Uniform Resource
  241. Identifier can be further classified either a Uniform Resource Locator
  242. (URL) or a Uniform Resource Name (URN). The distinction between URL
  243. and URN does not matter to the C<URI> class interface. A
  244. "URI-reference" is a URI that may have additional information attached
  245. in the form of a fragment identifier.
  246. An absolute URI reference consists of three parts. A I<scheme>, a
  247. I<scheme specific part> and a I<fragment> identifier. A subset of URI
  248. references share a common syntax for hierarchical namespaces. For
  249. these the scheme specific part is further broken down into
  250. I<authority>, I<path> and I<query> components. These URI can also
  251. take the form of relative URI references, where the scheme (and
  252. usually also the authority) component is missing, but implied by the
  253. context of the URI reference. The three forms of URI reference
  254. syntax are summarized as follows:
  255. <scheme>:<scheme-specific-part>#<fragment>
  256. <scheme>://<authority><path>?<query>#<fragment>
  257. <path>?<query>#<fragment>
  258. The components that a URI reference can be divided into depend on the
  259. I<scheme>. The C<URI> class provides methods to get and set the
  260. individual components. The methods available for a specific
  261. C<URI> object depend on the scheme.
  262. =head1 CONSTRUCTORS
  263. The following methods construct new C<URI> objects:
  264. =over 4
  265. =item $uri = URI->new( $str, [$scheme] )
  266. This class method constructs a new URI object. The string
  267. representation of a URI is given as argument together with an optional
  268. scheme specification. Common URI wrappers like "" and <>, as well as
  269. leading and trailing white space, are automatically removed from
  270. the $str argument before it is processed further.
  271. The constructor determines the scheme, maps this to an appropriate
  272. URI subclass, constructs a new object of that class and returns it.
  273. The $scheme argument is only used when $str is a
  274. relative URI. It can either be a simple string that
  275. denotes the scheme, a string containing an absolute URI reference or
  276. an absolute C<URI> object. If no $scheme is specified for a relative
  277. URI $str, then $str is simply treated as a generic URI (no scheme
  278. specific methods available).
  279. The set of characters available for building URI references is
  280. restricted (see L<URI::Escape>). Characters outside this set are
  281. automatically escaped by the URI constructor.
  282. =item $uri = URI->new_abs( $str, $base_uri )
  283. This constructs a new absolute URI object. The $str argument can
  284. denote a relative or absolute URI. If relative, then it will be
  285. absolutized using $base_uri as base. The $base_uri must be an absolute
  286. URI.
  287. =item $uri = URI::file->new( $filename, [$os] )
  288. This constructs a new I<file> URI from a file name. See L<URI::file>.
  289. =item $uri = URI::file->new_abs( $filename, [$os] )
  290. This constructs a new absolute I<file> URI from a file name. See
  291. L<URI::file>.
  292. =item $uri = URI::file->cwd
  293. This returns the current working directory as a I<file> URI. See
  294. L<URI::file>.
  295. =item $uri->clone
  296. This method returns a copy of the $uri.
  297. =back
  298. =head1 COMMON METHODS
  299. The methods described in this section are available for all C<URI>
  300. objects.
  301. Methods that give access to components of a URI will always return the
  302. old value of the component. The value returned will be C<undef> if the
  303. component was not present. There is generally a difference between a
  304. component that is empty (represented as C<"">) and a component that is
  305. missing (represented as C<undef>). If an accessor method is given an
  306. argument it will update the corresponding component in addition to
  307. returning the old value of the component. Passing an undefined
  308. argument will remove the component (if possible). The description of
  309. the various accessor methods will tell if the component is passed as
  310. an escaped or an unescaped string. Components that can be futher
  311. divided into sub-parts are usually passed escaped, as unescaping might
  312. change its semantics.
  313. The common methods available for all URI are:
  314. =over 4
  315. =item $uri->scheme( [$new_scheme] )
  316. This method sets and returns the scheme part of the $uri. If the $uri is
  317. relative, then $uri->scheme returns C<undef>. If called with an
  318. argument, it will update the scheme of $uri, possibly changing the
  319. class of $uri, and return the old scheme value. The method croaks
  320. if the new scheme name is illegal; scheme names must begin with a
  321. letter and must consist of only US-ASCII letters, numbers, and a few
  322. special marks: ".", "+", "-". This restriction effectively means
  323. that scheme have to be passed unescaped. Passing an undefined
  324. argument to the scheme method will make the URI relative (if possible).
  325. Letter case does not matter for scheme names. The string
  326. returned by $uri->scheme is always lowercase. If you want the scheme
  327. just as it was written in the URI in its original case,
  328. you can use the $uri->_scheme method instead.
  329. =item $uri->opaque( [$new_opaque] )
  330. This method sets and returns the scheme specific part of the $uri
  331. (everything between the scheme and the fragment)
  332. as an escaped string.
  333. =item $uri->path( [$new_path] )
  334. This method sets and returns the same value as $uri->opaque unless the URI
  335. supports the generic syntax for hierarchical namespaces.
  336. In that case the generic method is overridden to set and return
  337. the part of the URI between the I<host name> and the I<fragment>.
  338. =item $uri->fragment( [$new_frag] )
  339. This method returns the fragment identifier of a URI reference
  340. as an escaped string.
  341. =item $uri->as_string
  342. This method returns a URI object to a plain string. URI objects are
  343. also converted to plain strings automatically by overloading. This
  344. means that $uri objects can be used as plain strings in most Perl
  345. constructs.
  346. =item $uri->canonical
  347. This method will return a normalized version of the URI. The rules
  348. for normalization are scheme dependent. It usually involves
  349. lowercasing of the scheme and the Internet host name components,
  350. removing the explicit port specification if it matches the default port,
  351. uppercasing all escape sequences, and unescaping octets that can be
  352. better represented as plain characters.
  353. For efficiency reasons, if the $uri already was in normalized form,
  354. then a reference to it is returned instead of a copy.
  355. =item $uri->eq( $other_uri )
  356. =item URI::eq( $first_uri, $other_uri )
  357. This method tests whether two URI references are equal. URI references
  358. that normalize to the same string are considered equal. The method
  359. can also be used as a plain function which can also test two string
  360. arguments.
  361. If you need to test whether two C<URI> object references denote the
  362. same object, use the '==' operator.
  363. =item $uri->abs( $base_uri )
  364. This method returns an absolute URI reference. If $uri already is
  365. absolute, then a reference to it is simply returned. If the $uri
  366. is relative, then a new absolute URI is constructed by combining the
  367. $uri and the $base_uri, and returned.
  368. =item $uri->rel( $base_uri )
  369. This method returns a relative URI reference if it is possible to
  370. make one that denotes the same resource relative to $base_uri.
  371. If not, then $uri is simply returned.
  372. =back
  373. =head1 GENERIC METHODS
  374. The following methods are available to schemes that use the
  375. common/generic syntax for hierarchical namespaces. The description of
  376. schemes below will tell which one these are. Unknown schemes are
  377. assumed to support the generic syntax, and therefore the following
  378. methods:
  379. =over 4
  380. =item $uri->authority( [$new_authority] )
  381. This method sets and returns the escaped authority component
  382. of the $uri.
  383. =item $uri->path( [$new_path] )
  384. This method sets and returns the escaped path component of
  385. the $uri (the part between the host name and the query or fragment).
  386. The path will never be undefined, but it can be the empty string.
  387. =item $uri->path_query( [$new_path_query] )
  388. This method sets and returns the escaped path and query
  389. components as a single entity. The path and the query are
  390. separated by a "?" character, but the query can itself contain "?".
  391. =item $uri->path_segments( [$segment,...] )
  392. This method sets and returns the path. In scalar context it returns
  393. the same value as $uri->path. In list context it will return the
  394. unescaped path segments that make up the path. Path segments that
  395. have parameters are returned as an anonymous array. The first element
  396. is the unescaped path segment proper. Subsequent elements are escaped
  397. parameter strings. Such an anonymous array uses overloading so it can
  398. be treated as a string too, but this string does not include the
  399. parameters.
  400. =item $uri->query( [$new_query] )
  401. This method sets and returns the escaped query component of
  402. the $uri.
  403. =item $uri->query_form( [$key => $value,...] )
  404. This method sets and returns query components that use the
  405. I<application/x-www-form-urlencoded> format. Key/value pairs are
  406. separated by "&" and the key is separated from the value with a "="
  407. character.
  408. =item $uri->query_keywords( [$keywords,...] )
  409. This method sets and returns query components that use the
  410. keywords separated by "+" format.
  411. =back
  412. =head1 SERVER METHODS
  413. Schemes where the I<authority> component denotes a Internet host will
  414. have the following methods available in addition to the generic
  415. methods.
  416. =over 4
  417. =item $uri->userinfo( [$new_userinfo] )
  418. This method sets and returns the escaped userinfo part of the
  419. authority componenent.
  420. For some schemes this will be a user name and a password separated by
  421. a colon. This practice is not recommended. Embedding passwords in
  422. clear text (such as URI) has proven to be a security risk in almost
  423. every case where it has been used.
  424. =item $uri->host( [$new_host] )
  425. This method sets and returns the unescaped hostname.
  426. If the $new_host string ends with a colon and a number, then this
  427. number will also set the port.
  428. =item $uri->port( [ $new_port] )
  429. This method sets and returns the port. The port is simple integer
  430. that should be greater than 0.
  431. If no explicit port is specified in the URI, then the default port of
  432. the URI scheme is returned. If you don't want the default port
  433. substituted, then you can use the $uri->_port method instead.
  434. =item $uri->host_port( [ $new_host_port ] )
  435. This method sets and returns the host and port as a single
  436. unit. The returned value will include a port, even if it matches the
  437. default port. The host part and the port part is separated with a
  438. colon; ":".
  439. =item $uri->default_port
  440. This method returns the default port of the URI scheme that $uri
  441. belongs to. For I<http> this will be the number 80, for I<ftp> this
  442. will be the number 21, etc. The default port for a scheme can not be
  443. changed.
  444. =back
  445. =head1 SCHEME SPECIFIC SUPPORT
  446. The following URI schemes are specifically supported. For C<URI>
  447. objects not belonging to one of these you can only use the common and
  448. generic methods.
  449. =over 4
  450. =item B<data>:
  451. The I<data> URI scheme is specified in RFC 2397. It allows inclusion
  452. of small data items as "immediate" data, as if it had been included
  453. externally.
  454. C<URI> objects belonging to the data scheme support the common methods
  455. and two new methods to access their scheme specific components;
  456. $uri->media_type and $uri->data. See L<URI::data> for details.
  457. =item B<file>:
  458. An old specification of the I<file> URI scheme is found in RFC 1738.
  459. A new RFC 2396 based specification in not available yet, but file URI
  460. references are in common use.
  461. C<URI> objects belonging to the file scheme support the common and
  462. generic methods. In addition they provide two methods to map file URI
  463. back to local file names; $uri->file and $uri->dir. See L<URI::file>
  464. for details.
  465. =item B<ftp>:
  466. An old specification of the I<ftp> URI scheme is found in RFC 1738. A
  467. new RFC 2396 based specification in not available yet, but ftp URI
  468. references are in common use.
  469. C<URI> objects belonging to the ftp scheme support the common,
  470. generic and server methods. In addition they provide two methods to
  471. access the userinfo sub-components: $uri->user and $uri->password.
  472. =item B<gopher>:
  473. The I<gopher> URI scheme is specified in
  474. <draft-murali-url-gopher-1996-12-04> and will hopefully be available
  475. as a RFC 2396 based specification.
  476. C<URI> objects belonging to the gopher scheme support the common,
  477. generic and server methods. In addition they support some methods to
  478. access gopher specific path components: $uri->gopher_type,
  479. $uri->selector, $uri->search, $uri->string.
  480. =item B<http>:
  481. The I<http> URI scheme is specified in
  482. <draft-ietf-http-v11-spec-rev-06> (which will become an RFC soon).
  483. The scheme is used to reference resources hosted by HTTP servers.
  484. C<URI> objects belonging to the http scheme support the common,
  485. generic and server methods.
  486. =item B<https>:
  487. The I<https> URI scheme is a Netscape invention which is commonly
  488. implemented. The scheme is used to reference HTTP servers through SSL
  489. connections. It's syntax is the same as http, but the default
  490. port is different.
  491. =item B<ldap>:
  492. The I<ldap> URI scheme is specified in RFC 2255. LDAP is the
  493. Lightweight Directory Access Protocol. A ldap URI describes an LDAP
  494. search operation to perform to retrieve information from an LDAP
  495. directory.
  496. C<URI> objects belonging to the ldap scheme support the common,
  497. generic and server methods as well as specific ldap methods; $uri->dn,
  498. $uri->attributes, $uri->scope, $uri->filter, $uri->extensions. See
  499. L<URI::ldap> for details.
  500. =item B<mailto>:
  501. The I<mailto> URI scheme is specified in RFC 2368. The scheme was
  502. originally used to designate the Internet mailing address of an
  503. individual or service. It has (in RFC 2368) been extended to allow
  504. setting of other mail header fields and the message body.
  505. C<URI> objects belonging to the mailto scheme support the common
  506. methods and the generic query methods. In addition they support the
  507. following mailto specific methods: $uri->to, $uri->headers.
  508. =item B<news>:
  509. The I<news>, I<nntp> and I<snews> URI schemes are specified in
  510. <draft-gilman-news-url-01> and will hopefully be available as a RFC
  511. 2396 based specification soon.
  512. C<URI> objects belonging to the news scheme support the common,
  513. generic and server methods. In addition they provide some methods to
  514. access the path: $uri->group and $uri->message.
  515. =item B<nntp>:
  516. See I<news> scheme.
  517. =item B<pop>:
  518. The I<pop> URI scheme is specified in RFC 2384. The scheme is used to
  519. reference a POP3 mailbox.
  520. C<URI> objects belonging to the pop scheme support the common, generic
  521. and server methods. In addition they provide two methods to access the
  522. userinfo components: $uri->user and $uri->auth
  523. =item B<rlogin>:
  524. An old speficication of the I<rlogin> URI scheme is found in RFC
  525. 1738. C<URI> objects belonging to the rlogin scheme support the
  526. common, generic and server methods.
  527. =item B<snews>:
  528. See I<news> scheme. It's syntax is the same as news, but the default
  529. port is different.
  530. =item B<telnet>:
  531. An old speficication of the I<telnet> URI scheme is found in RFC
  532. 1738. C<URI> objects belonging to the telnet scheme support the
  533. common, generic and server methods.
  534. =back
  535. =head1 CONFIGURATION VARIABLES
  536. The following configuration variables influence how the class and it's
  537. methods behave:
  538. =over 4
  539. =item $URI::ABS_ALLOW_RELATIVE_SCHEME
  540. Some older parsers used to allow the scheme name to be present in the
  541. relative URL if it was the same as the base URL scheme. RFC 2396 says
  542. that this should be avoided, but you can enable this old behaviour by
  543. setting the $URI::ABS_ALLOW_RELATIVE_SCHEME variable to a TRUE value.
  544. The difference is demonstrated by the following examples:
  545. URI->new("http:foo")->abs("http://host/a/b")
  546. ==> "http:foo"
  547. local $URI::ABS_ALLOW_RELATIVE_SCHEME = 1;
  548. URI->new("http:foo")->abs("http://host/a/b")
  549. ==> "http:/host/a/foo"
  550. =item $URI::ABS_REMOTE_LEADING_DOTS
  551. You can also have the abs() method ignore excess ".."
  552. segments in the relative URI by setting $URI::ABS_REMOTE_LEADING_DOTS
  553. to a TRUE value. The difference is demonstrated by the following
  554. examples:
  555. URI->new("../../../foo")->abs("http://host/a/b")
  556. ==> "http://host/../../foo"
  557. local $URI::URL::ABS_REMOTE_LEADING_DOTS = 1;
  558. URI->new("../../../foo")->abs("http://host/a/b")
  559. ==> "http://host/foo"
  560. =back
  561. =head1 SEE ALSO
  562. L<URI::file>, L<URI::WithBase>, L<URI::Escape>, L<URI::Heuristic>
  563. RFC 2396: "Uniform Resource Identifiers (URI): Generic Syntax",
  564. Berners-Lee, Fielding, Masinter, August 1998.
  565. =head1 COPYRIGHT
  566. Copyright 1995-1999 Gisle Aas.
  567. Copyright 1995 Martijn Koster.
  568. This program is free software; you can redistribute it and/or modify
  569. it under the same terms as Perl itself.
  570. =head1 AUTHORS / ACKNOWLEDGMENTS
  571. This module is based on the C<URI::URL> module, which in turn was
  572. (distantly) based on the C<wwwurl.pl> code in the libwww-perl for
  573. perl4 developed by Roy Fielding, as part of the Arcadia project at the
  574. University of California, Irvine, with contributions from Brooks
  575. Cutter.
  576. C<URI::URL> was developed by Gisle Aas, Tim Bunce, Roy Fielding and
  577. Martijn Koster with input from other people on the libwww-perl mailing
  578. list.
  579. C<URI> and related subclasses was developed by Gisle Aas.
  580. =cut