FIX: Don't normalize URLs before fetching them, only for saving them

This commit is contained in:
Robin Ward 2015-11-06 16:25:11 -05:00
parent 355215ca91
commit e2b5919579
1 changed files with 4 additions and 5 deletions

View File

@ -65,7 +65,6 @@ class TopicEmbed < ActiveRecord::Base
def self.find_remote(url) def self.find_remote(url)
require 'ruby-readability' require 'ruby-readability'
url = normalize_url(url)
original_uri = URI.parse(url) original_uri = URI.parse(url)
opts = { opts = {
tags: %w[div p code pre h1 h2 h3 b em i strong a img ul li ol blockquote], tags: %w[div p code pre h1 h2 h3 b em i strong a img ul li ol blockquote],
@ -99,12 +98,12 @@ class TopicEmbed < ActiveRecord::Base
end end
# only allow classes in the whitelist # only allow classes in the whitelist
allowed_classes = if embed_classname_whitelist.blank? then [] else embed_classname_whitelist.split(/[ ,]+/i) end allowed_classes = if embed_classname_whitelist.blank? then [] else embed_classname_whitelist.split(/[ ,]+/i) end
doc.search('[class]:not([class=""])').each do |node| doc.search('[class]:not([class=""])').each do |classnode|
classes = node[:class].split(' ').select{ |classname| allowed_classes.include?(classname) } classes = classnode[:class].split(' ').select{ |classname| allowed_classes.include?(classname) }
if classes.length === 0 if classes.length === 0
node.delete('class') classnode.delete('class')
else else
node[:class] = classes.join(' ') classnode[:class] = classes.join(' ')
end end
end end
end end