From 2434c73a0cf96bc09ef3e997c337bafbb15128a9 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Tue, 24 Jan 2017 09:52:38 +0100 Subject: [PATCH] Remove unneeded HTML scrabber in protocol importer [SCI-921] --- app/helpers/tiny_mce_js_helper.rb | 17 ----------------- app/utilities/protocols_importer.rb | 9 +++------ app/utilities/scrubbers/tiny_mce_js_scrubber.rb | 11 ----------- 3 files changed, 3 insertions(+), 34 deletions(-) delete mode 100644 app/helpers/tiny_mce_js_helper.rb delete mode 100644 app/utilities/scrubbers/tiny_mce_js_scrubber.rb diff --git a/app/helpers/tiny_mce_js_helper.rb b/app/helpers/tiny_mce_js_helper.rb deleted file mode 100644 index 1ce2b0db2..000000000 --- a/app/helpers/tiny_mce_js_helper.rb +++ /dev/null @@ -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 diff --git a/app/utilities/protocols_importer.rb b/app/utilities/protocols_importer.rb index a69ffb6a1..99276a56a 100644 --- a/app/utilities/protocols_importer.rb +++ b/app/utilities/protocols_importer.rb @@ -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, diff --git a/app/utilities/scrubbers/tiny_mce_js_scrubber.rb b/app/utilities/scrubbers/tiny_mce_js_scrubber.rb deleted file mode 100644 index 6cf6e296a..000000000 --- a/app/utilities/scrubbers/tiny_mce_js_scrubber.rb +++ /dev/null @@ -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