From fc42034d6386b5ee7abbee0199786c87d15db15c Mon Sep 17 00:00:00 2001 From: Elz Date: Wed, 4 Oct 2017 14:48:44 -0400 Subject: [PATCH] AO3-5192: Add sites to https list, rescue to after task (#3099) --- .../gem-plugin_config/sanitizer_config.rb | 2 ++ lib/tasks/after_tasks.rake | 11 +++++++++-- spec/lib/html_cleaner_spec.rb | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/config/initializers/gem-plugin_config/sanitizer_config.rb b/config/initializers/gem-plugin_config/sanitizer_config.rb index b0618750bfe..16569c75bee 100644 --- a/config/initializers/gem-plugin_config/sanitizer_config.rb +++ b/config/initializers/gem-plugin_config/sanitizer_config.rb @@ -121,9 +121,11 @@ module Transformers allow_flashvars = ["ning", "vidders.net", "google", "criticalcommons", "archiveofourown", "podfic", "spotify", "8tracks", "soundcloud"] supports_https = [ + "8tracks", "archiveorg", "archiveofourown", "dailymotion", + "podfic", "soundcloud", "spotify", "viddertube", diff --git a/lib/tasks/after_tasks.rake b/lib/tasks/after_tasks.rake index 4b87eec9261..606d70f6d95 100644 --- a/lib/tasks/after_tasks.rake +++ b/lib/tasks/after_tasks.rake @@ -568,9 +568,16 @@ namespace :After do desc "Enforce HTTPS where available for embedded media" task(enforce_https: :environment) do Chapter.find_each do |chapter| + if chapter.id % 1000 == 0 + puts chapter.id + end if chapter.content.match /<(embed|iframe)/ - chapter.content_sanitizer_version = -1 - chapter.sanitize_field(chapter, :content) + begin + chapter.content_sanitizer_version = -1 + chapter.sanitize_field(chapter, :content) + rescue + puts "couldn't update chapter #{chapter.id}" + end end end end diff --git a/spec/lib/html_cleaner_spec.rb b/spec/lib/html_cleaner_spec.rb index 5237a4ad977..221d2d40c19 100644 --- a/spec/lib/html_cleaner_spec.rb +++ b/spec/lib/html_cleaner_spec.rb @@ -235,7 +235,7 @@ end %w{youtube.com youtube-nocookie.com vimeo.com player.vimeo.com - archiveofourown.org archive.org dailymotion.com + archiveofourown.org archive.org dailymotion.com 8tracks.com podfic.com embed.spotify.com spotify.com w.soundcloud.com soundcloud.com viddertube.com}.each do |source| it "should convert to https for #{source}" do @@ -245,7 +245,7 @@ end end - %w(metacafe.com vidders.net criticalcommons.org 8tracks.com static.ning.com ning.com podfic.com).each do |source| + %w(metacafe.com vidders.net criticalcommons.org static.ning.com ning.com).each do |source| it "should not convert to https for #{source}" do html = '' result = sanitize_value(:content, html)