mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-17 08:16:29 +00:00
fix: eliminar el elemento sin src válido en un solo lugar
This commit is contained in:
parent
5611042c58
commit
ecff604c8e
1 changed files with 3 additions and 6 deletions
|
@ -47,16 +47,13 @@ class MetadataContent < MetadataTemplate
|
|||
|
||||
# Eliminar elementos sin src y comprobar su origen
|
||||
html.css(elements).each do |element|
|
||||
unless element['src']
|
||||
element.remove
|
||||
next
|
||||
end
|
||||
|
||||
begin
|
||||
raise URI::Error unless element['src'].present?
|
||||
|
||||
uri = URI element['src']
|
||||
|
||||
# No permitimos recursos externos
|
||||
element.remove unless uri.scheme == 'https' && uri.hostname.end_with?(Site.domain)
|
||||
raise URI::Error unless Rails.application.config.hosts.include?(uri.hostname)
|
||||
rescue URI::Error
|
||||
element.remove
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue