Skip to content

Commit

Permalink
remove colon from pair "user:pass" if has no password
Browse files Browse the repository at this point in the history
(closes github issue libwww-perl#13)
  • Loading branch information
joenio committed Jan 24, 2016
1 parent c6b1466 commit fa47826
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/URI/_userpass.pm
Expand Up @@ -40,8 +40,8 @@ sub password
my $user = defined($info) ? $info : "";
$user =~ s/:.*//;

if (!defined($new) && !length($user)) {
$self->userinfo(undef);
if (!defined($new)) {
$self->userinfo($user || undef);
} else {
$new = "" unless defined($new);
$new =~ s/%/%25/g;
Expand Down
12 changes: 12 additions & 0 deletions t/userpass.t
@@ -0,0 +1,12 @@
use strict;
use warnings;

print "1..1\n";

use URI;

my $uri = URI->new("rsync://foo:bar\@example.com");
$uri->password(undef);

print "not " if $uri->as_string =~ /foo:\@example.com/;
print "ok 1\n";

0 comments on commit fa47826

Please sign in to comment.