Skip to content

Commit

Permalink
AO3-5192: Add sites to https list, rescue to after task (#3099)
Browse files Browse the repository at this point in the history
  • Loading branch information
elzj authored and zz9pzza committed Oct 4, 2017
1 parent 27d1d4f commit fc42034
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions config/initializers/gem-plugin_config/sanitizer_config.rb
Expand Up @@ -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",
Expand Down
11 changes: 9 additions & 2 deletions lib/tasks/after_tasks.rake
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/html_cleaner_spec.rb
Expand Up @@ -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
Expand All @@ -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 = '<iframe width="560" height="315" src="http://' + source + '/embed/123" frameborder="0"></iframe>'
result = sanitize_value(:content, html)
Expand Down

0 comments on commit fc42034

Please sign in to comment.