Skip to content

Commit 6d28873

Browse files
committed
Check for private address early
`PrivateAddressCheck::PrivateConnectionAttemptedError` will not be raised by `PrivateAddressCheck.only_public_connections` if another exception happens beforehand (e.g. `IO::TimeoutError`)
1 parent c63ed77 commit 6d28873

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

app/validators/http_url_validator.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def accessible?(value)
99
code = nil
1010
begin
1111
uri = URI.parse(value) rescue nil
12+
return false if PrivateAddressCheck.resolves_to_private_address?(uri.hostname)
1213
if uri && (uri.scheme == 'http' || uri.scheme == 'https')
1314
PrivateAddressCheck.only_public_connections do
1415
res = HTTParty.get(value, { timeout: Rails.env.test? ? 1 : 5 })

0 commit comments

Comments
 (0)