Subject: | UserAgent->Proxy Bug Report |
Date: | Thu, 9 Oct 2008 08:25:37 -0700 |
To: | gisle [...] ActiveState.com, bug-libwww-perl [...] rt.cpan.org |
From: | "Evan Duffield" <eduffield [...] gmail.com> |
Hello,
My issue with user agent is simple.
When called with one scalar like: $ua->proxy($proxy_addr)
This trys to look for a proxy under a scheme matching $proxy_addr. What if
you were trying to set the proxy? You just did it wrong, and UserAgent
didn't complain or anything. So at this point I am accessing the internet
without being protected, and you don't even know it.
I suggest the proxy sub by split into get_proxy and set_proxy to limit
further confusion.
Here's the examples:
$ua->proxy(\@schemes, $proxy_url); #called correctly
$ua->proxy(['http','https'], 'http://' . $p); #called incorrectly
$ua->proxy('http'); #returning correct scheme proxy
$ua->proxy($proxy_url); #returning undef! No error or
anything!
From useragent:
sub proxy
{
my $self = shift;
my $key = shift;
return map $self->proxy($_, @_), @$key if ref $key;
my $old = $self->{'proxy'}{$key};
if (@_) {
$self->{proxy}{$key} = shift;
$self->set_my_handler("request_preprepare", \&_need_proxy)
}
return $old;
}