mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 15:16:08 +08:00
FIX: Swallow SSL errors when generating oneboxes
This commit is contained in:
parent
14cc67c9b2
commit
afe7785141
|
@ -192,13 +192,13 @@ class FinalDestination
|
|||
|
||||
if @limit < 0
|
||||
@status = :too_many_redirects
|
||||
log(:warn, "FinalDestination could not resolve URL (too many redirects): #{@uri}") if @verbose
|
||||
log(:warn, "FinalDestination could not resolve URL (too many redirects): #{@uri}")
|
||||
return
|
||||
end
|
||||
|
||||
unless validate_uri
|
||||
@status = :invalid_address
|
||||
log(:warn, "FinalDestination could not resolve URL (invalid URI): #{@uri}") if @verbose
|
||||
log(:warn, "FinalDestination could not resolve URL (invalid URI): #{@uri}")
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -344,10 +344,10 @@ class FinalDestination
|
|||
@status = :failure
|
||||
@status_code = response.status
|
||||
|
||||
log(:warn, "FinalDestination could not resolve URL (status #{response.status}): #{@uri}") if @verbose
|
||||
log(:warn, "FinalDestination could not resolve URL (status #{response.status}): #{@uri}")
|
||||
nil
|
||||
rescue Excon::Errors::Timeout
|
||||
log(:warn, "FinalDestination could not resolve URL (timeout): #{@uri}") if @verbose
|
||||
log(:warn, "FinalDestination could not resolve URL (timeout): #{@uri}")
|
||||
nil
|
||||
end
|
||||
|
||||
|
@ -427,6 +427,7 @@ class FinalDestination
|
|||
end
|
||||
|
||||
def log(log_level, message)
|
||||
return unless @verbose
|
||||
return if @status_code == 404
|
||||
|
||||
Rails.logger.public_send(
|
||||
|
@ -519,7 +520,10 @@ class FinalDestination
|
|||
|
||||
result
|
||||
rescue Timeout::Error
|
||||
log(:warn, "FinalDestination could not resolve URL (timeout): #{@uri}") if @verbose
|
||||
log(:warn, "FinalDestination could not resolve URL (timeout): #{@uri}")
|
||||
nil
|
||||
rescue OpenSSL::SSL::SSLError => exception
|
||||
log(:warn, "An error with SSL occurred: #{@uri} #{exception.message}")
|
||||
nil
|
||||
rescue StandardError
|
||||
unsafe_close ? [:ok, headers_subset] : raise
|
||||
|
|
|
@ -470,6 +470,23 @@ RSpec.describe FinalDestination do
|
|||
expect(get).to be_blank
|
||||
end
|
||||
end
|
||||
|
||||
context "when there is an SSL error" do
|
||||
subject(:get) { fd.get {} }
|
||||
|
||||
before do
|
||||
fd.stubs(:safe_session).raises(OpenSSL::SSL::SSLError)
|
||||
end
|
||||
|
||||
it "logs the exception" do
|
||||
Rails.logger.expects(:warn).with(regexp_matches(/an error with ssl occurred/i))
|
||||
get
|
||||
end
|
||||
|
||||
it "returns nothing" do
|
||||
expect(get).to be_blank
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '.validate_uri' do
|
||||
|
|
Loading…
Reference in New Issue
Block a user