FIX: Respect blocked domains list when redirecting (#15656)

Our previous implementation used a simple `blocked_domain_array.include?(hostname)`
so some values were not matching. Additionally, in some configurations like ours, we'd used
"cat.*.dog.com" with the assumption we'd support globbing.

This change implicitly allows globbing by blocking "http://a.b.com" if "b.com" is a blocked 
domain but does not actively do anything for "*".

An upcoming change might include frontend validation for values that can be inserted.
This commit is contained in:
Natalie Tay
2022-01-20 14:12:34 +08:00
committed by GitHub
parent 191bdac4f0
commit f5ea00c73f
4 changed files with 73 additions and 9 deletions

View File

@ -60,6 +60,10 @@ module RetrieveTitle
encoding = nil
fd.get do |_response, chunk, uri|
if (uri.present? && InlineOneboxer.domain_is_blocked?(uri.hostname))
throw :done
end
unless Net::HTTPRedirection === _response
if current
current << chunk