Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URI leaves ".." in absolute path (via new_abs()) #52

Open
hadjiprocopis opened this issue Mar 29, 2018 · 0 comments
Open

URI leaves ".." in absolute path (via new_abs()) #52

hadjiprocopis opened this issue Mar 29, 2018 · 0 comments

Comments

@hadjiprocopis
Copy link

I wonder if it is expected behaviour from URI's url absolution (ok absolutisation) to still retain relative path components in final url. Someone (ikegami) at perlmonks said that this is violation of section 5.4.2 of RFC 3986

Here is a script to reproduce the problem (using perl 5.22, URI v1.73, LWP::UserAgent v6.33) :

!/usr/bin/env perl

use strict;
use warnings;
use URI;

# a relative url:
my $rel_url = '../../../../../abc.html';
# the base url, where I stand now:
my @base_uris = ('http://server.com/123/xyz',
'http://server.com/1/2/3/4/5',
'http://server.com/1/2/3/4/5/');

# URI's absolute url:
foreach my $abase (@base_uris){
   my $uri = URI->new_abs( $rel_url, $abase );
   print "absolute for base: $abase is\n\t".$uri."\n";
}

yields:

    http://server.com/../../../../abc.html
absolute for base: http://server.com/1/2/3/4/5 is
    http://server.com/../abc.html
absolute for base: http://server.com/1/2/3/4/5/ is
    http://server.com/abc.html

The last response is correct but I wonder whether for the first two cases URI should have used some heuristics to remove that ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant