Skip to content

Commit

Permalink
Allow IPv6 proxy hosts starting with [.
Browse files Browse the repository at this point in the history
Altered the regular expression that checked for a sane-ish looking
URL for our proxy host:

 if $url =~ /^https?:/ && $url !~ m,^https?://\w,;

Given this expression, a proxy host in the form of
http://[::1]:33485/ would fail because it starts with a left bracket.

The expression above has been altered to:

 if $url =~ /^https?:/ && $url !~ m,^https?://[\w[],;

Which will allow it to begin with a word character or a left bracket.

This will resolve issue #237
  • Loading branch information
genio committed Mar 4, 2019
1 parent 04c14ca commit 6c420f7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Change history for libwww-perl

{{$NEXT}}
- Improve ->add_handler documentation (GH #272) (Julien Fiegehenn)
- Alter our rule set to allow IPv6 proxy hosts beginning with [. (GH #237)

6.36 2018-10-10 02:20:58Z
- fix broken link https://metacpan.org/pod/LWP::Simple by fixing pod
Expand Down
2 changes: 1 addition & 1 deletion lib/LWP/UserAgent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ sub proxy {
my $url = shift;
if (defined($url) && length($url)) {
Carp::croak("Proxy must be specified as absolute URI; '$url' is not") unless $url =~ /^$URI::scheme_re:/;
Carp::croak("Bad http proxy specification '$url'") if $url =~ /^https?:/ && $url !~ m,^https?://\w,;
Carp::croak("Bad http proxy specification '$url'") if $url =~ /^https?:/ && $url !~ m,^https?://[\w[],;
}
$self->{proxy}{$key} = $url;
$self->set_my_handler("request_preprepare", \&_need_proxy)
Expand Down

0 comments on commit 6c420f7

Please sign in to comment.