Merge pull request #438 from okriuchykhin/ok_SCI_921

Remove unneeded HTML scrubber in protocol importer [SCI-921]
This commit is contained in:
okriuchykhin 2017-01-24 11:02:43 +01:00 committed by GitHub
commit 7fa1f3d966
3 changed files with 3 additions and 34 deletions

View file

@ -1,17 +0,0 @@
module TinyMceJsHelper
def sanitize_tiny_mce_js_input(input)
require "#{Rails.root}/app/utilities/scrubbers/tiny_mce_js_scrubber"
# We need to disable formatting to prevent unwanted \n
# symbols from creeping into sanitized HTML (which
# cause unwanted new lines when rendered in Quill.js)
disable_formatting =
Nokogiri::XML::Node::SaveOptions::DEFAULT_HTML ^
Nokogiri::XML::Node::SaveOptions::FORMAT
Loofah
.fragment(input)
.scrub!(TinyMceJsScrubber.new)
.to_html(save_with: disable_formatting)
end
end

View file

@ -1,5 +1,5 @@
module ProtocolsImporter
include RenamingUtil, TinyMceJsHelper
include RenamingUtil
def import_new_protocol(protocol_json, organization, type, user)
remove_empty_inputs(protocol_json)
@ -52,11 +52,8 @@ module ProtocolsImporter
if protocol_json['steps']
protocol_json['steps'].values.each do |step_json|
step = Step.create!(
name: step_json["name"],
description: # Sanitize description HTML
sanitize_tiny_mce_js_input(
step_json['description']
),
name: step_json['name'],
description: step_json['description'],
position: step_pos,
completed: false,
user: user,

View file

@ -1,11 +0,0 @@
class QuillJsScrubber < Rails::Html::PermitScrubber
def initialize
super
self.tags = %w(h1 span p br pre ul li strong em u sub sup s a blockquote ol)
self.attributes = %w(style class spellcheck href target)
end
def skip_node?(node)
node.text?
end
end