aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/uri/generic.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb
index f2a2d567e3..3c4cb6e530 100644
--- a/lib/uri/generic.rb
+++ b/lib/uri/generic.rb
@@ -1547,9 +1547,18 @@ module URI
name = 'no_proxy'
if no_proxy = ENV[name] || ENV[name.upcase]
no_proxy.scan(/(?!\.)([^:,\s]+)(?::(\d+))?/) {|host, port|
- if /(\A|\.)#{Regexp.quote host}\z/i =~ self.host &&
- (!port || self.port == port.to_i)
- return nil
+ if (!port || self.port == port.to_i)
+ if /(\A|\.)#{Regexp.quote host}\z/i =~ self.host
+ return nil
+ else
+ require 'ipaddr'
+ return nil if
+ begin
+ IPAddr.new(host)
+ rescue IPAddr::InvalidAddressError
+ next
+ end.include?(self.host)
+ end
end
}
end