diff --git a/app/models/metadata_content.rb b/app/models/metadata_content.rb index 9d3a1040..7598dc31 100644 --- a/app/models/metadata_content.rb +++ b/app/models/metadata_content.rb @@ -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