libwww-perl / URI

The Perl URI module
https://metacpan.org/pod/URI
Other
41 stars 48 forks source link

Using some special characters in http authentication broke URI parsing #143

Open kastakhov opened 1 month ago

kastakhov commented 1 month ago

URI lib cannot correctly parse next URI if its contain '#/?' symbols. For instance, next code:

use strict;
use warnings;
use v5.10;

use URI;

my $username = 'u1!"#$%&\'()*+,-./;<=>?@[\]^_`{|}~';
my $password = 'p2!"#$%&\'()*+,-./;<=>?@[\]^_`{|}~';
my $host = 'localhost';
my $port = '8080';

my $uri = URI->new("http://${username}:${password}\@${host}:${port}/path/to/file");
say $uri->scheme;
say $uri->host;
say $uri->port;
say $uri->path;
say $uri->authority;
say $uri->userinfo;

Produce the next output:

me@rogflowx13:~/libwww-perl$ perl test.pl
http
u1!"
80

u1!%22
Use of uninitialized value in say at test.pl line 25.