mirror of
https://0xacab.org/sutty/sutty
synced 2025-01-19 19:33:38 +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
|
# Eliminar elementos sin src y comprobar su origen
|
||||||
html.css(elements).each do |element|
|
html.css(elements).each do |element|
|
||||||
unless element['src']
|
|
||||||
element.remove
|
|
||||||
next
|
|
||||||
end
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
raise URI::Error unless element['src'].present?
|
||||||
|
|
||||||
uri = URI element['src']
|
uri = URI element['src']
|
||||||
|
|
||||||
# No permitimos recursos externos
|
# 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
|
rescue URI::Error
|
||||||
element.remove
|
element.remove
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue