mojolicious / mojo

:sparkles: Mojolicious - Perl real-time web framework
https://mojolicious.org
Artistic License 2.0
2.66k stars 576 forks source link

HTTP request fails when password is included in URL and contains a questionmark #1670

Closed maros closed 3 years ago

maros commented 3 years ago

Steps to reproduce the behavior

An error occurs when requesting an URL with username+password, when the password contains a question mark:

my $ua = Mojo::UserAgent->new;
say $ua->get('https://username:some?password@www.text.com')->res->body;

Expected behavior

Download of ressource should succeed

Actual behavior

An exception occurs

Can't connect: Servname not supported for ai_socktype
Mojo::IOLoop::__ANON__('Mojo::IOLoop::Client=HASH(0x55666fc45870)') called at /opt/gh/perl-current-live/local-default/lib/perl5/Mojo/EventEmitter.pm line 15 called by Mojo::EventEmitter::emit('Mojo::IOLoop::Client=HASH(0x55666fc45870)', 'error', 'Can\'t connect: Servname not supported for ai_socktype') called at /opt/gh/perl-current-live/local-default/lib/perl5/Mojo/IOLoop/Client.pm line 92
jberger commented 3 years ago

You need to URL encode your password perl -Mojo -E 'print r(Mojo::URL->new(q[http://this:th%3Fat@host.com/path]))'.