mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 23:07:28 +08:00
FIX: FinalDestination::HTTP: validate address argument (#25407)
This would only be empty due to a programming error elsewhere, but checking this here is a failstop so that it doesn't go further.
This commit is contained in:

committed by
GitHub

parent
0c63463d28
commit
508e2e601c
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
class FinalDestination::HTTP < Net::HTTP
|
class FinalDestination::HTTP < Net::HTTP
|
||||||
def connect
|
def connect
|
||||||
|
raise ArgumentError.new("address cannot be nil or empty") unless @address.present?
|
||||||
|
|
||||||
original_open_timeout = @open_timeout
|
original_open_timeout = @open_timeout
|
||||||
return super if @ipaddr
|
return super if @ipaddr
|
||||||
|
|
||||||
|
@ -110,4 +110,12 @@ describe FinalDestination::HTTP do
|
|||||||
FinalDestination::HTTP.start("example.com", 80, open_timeout: 5) {}
|
FinalDestination::HTTP.start("example.com", 80, open_timeout: 5) {}
|
||||||
end.to raise_error(Net::OpenTimeout)
|
end.to raise_error(Net::OpenTimeout)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "validates address argument against nil value" do
|
||||||
|
expect do FinalDestination::HTTP.start(nil) {} end.to raise_error(ArgumentError)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "validates address argument against empty value" do
|
||||||
|
expect do FinalDestination::HTTP.start("") {} end.to raise_error(ArgumentError)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user