mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 03:32:17 +08:00
FIX: follow redirects for inline/mini onebox (#13512)
This commit is contained in:
@ -57,24 +57,26 @@ module RetrieveTitle
|
||||
encoding = nil
|
||||
|
||||
fd.get do |_response, chunk, uri|
|
||||
unless Net::HTTPRedirection === _response
|
||||
if current
|
||||
current << chunk
|
||||
else
|
||||
current = chunk
|
||||
end
|
||||
|
||||
if current
|
||||
current << chunk
|
||||
else
|
||||
current = chunk
|
||||
end
|
||||
if !encoding && content_type = _response['content-type']&.strip&.downcase
|
||||
if content_type =~ /charset="?([a-z0-9_-]+)"?/
|
||||
encoding = Regexp.last_match(1)
|
||||
if !Encoding.list.map(&:name).map(&:downcase).include?(encoding)
|
||||
encoding = nil
|
||||
if !encoding && content_type = _response['content-type']&.strip&.downcase
|
||||
if content_type =~ /charset="?([a-z0-9_-]+)"?/
|
||||
encoding = Regexp.last_match(1)
|
||||
if !Encoding.list.map(&:name).map(&:downcase).include?(encoding)
|
||||
encoding = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
max_size = max_chunk_size(uri) * 1024
|
||||
title = extract_title(current, encoding)
|
||||
throw :done if title || max_size < current.length
|
||||
max_size = max_chunk_size(uri) * 1024
|
||||
title = extract_title(current, encoding)
|
||||
throw :done if title || max_size < current.length
|
||||
end
|
||||
end
|
||||
title
|
||||
end
|
||||
|
Reference in New Issue
Block a user