From c55f3cb99c2278019baff4ce7d30b1718bc02361 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Wed, 25 Jan 2017 17:15:22 +0100 Subject: [PATCH] Add flag to disable simple_format in custom_auto_link [SCI-940] --- app/datatables/sample_datatable.rb | 2 +- app/helpers/input_sanitize_helper.rb | 9 +++++++-- app/views/reports/elements/_result_text_element.html.erb | 2 +- .../reports/elements/_step_checklist_element.html.erb | 2 +- app/views/reports/elements/_step_element.html.erb | 2 +- app/views/results/_result_text.html.erb | 2 +- app/views/steps/_step.html.erb | 2 +- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/datatables/sample_datatable.rb b/app/datatables/sample_datatable.rb index 0102785ee..272ead960 100644 --- a/app/datatables/sample_datatable.rb +++ b/app/datatables/sample_datatable.rb @@ -130,7 +130,7 @@ class SampleDatatable < AjaxDatatablesRails::Base # Add custom attributes record.sample_custom_fields.each do |scf| sample[@cf_mappings[scf.custom_field_id]] = - custom_auto_link(scf.value, @organization) + custom_auto_link(scf.value, true, @organization) end sample end diff --git a/app/helpers/input_sanitize_helper.rb b/app/helpers/input_sanitize_helper.rb index 9593ff97e..3137ab392 100644 --- a/app/helpers/input_sanitize_helper.rb +++ b/app/helpers/input_sanitize_helper.rb @@ -11,9 +11,14 @@ module InputSanitizeHelper ERB::Util.html_escape(text) end - def custom_auto_link(text, org = nil) + def custom_auto_link(text, simple_format = true, org = nil) + text = if simple_format + simple_format(sanitize_input(text)) + else + sanitize_input(text) + end auto_link( - smart_annotation_parser(simple_format(sanitize_input(text)), org), + smart_annotation_parser(text, org), link: :urls, sanitize: false, html: { target: '_blank' } diff --git a/app/views/reports/elements/_result_text_element.html.erb b/app/views/reports/elements/_result_text_element.html.erb index 19b06e813..69a4fd40f 100644 --- a/app/views/reports/elements/_result_text_element.html.erb +++ b/app/views/reports/elements/_result_text_element.html.erb @@ -23,7 +23,7 @@
- <%= custom_auto_link(result_text.text) %> + <%= custom_auto_link(result_text.text, false) %>
diff --git a/app/views/reports/elements/_step_checklist_element.html.erb b/app/views/reports/elements/_step_checklist_element.html.erb index f2d8a2f6a..d674fd35e 100644 --- a/app/views/reports/elements/_step_checklist_element.html.erb +++ b/app/views/reports/elements/_step_checklist_element.html.erb @@ -8,7 +8,7 @@
- <%= custom_auto_link(t 'projects.reports.elements.step_checklist.checklist_name', name: checklist.name) %> + <%= custom_auto_link(t('projects.reports.elements.step_checklist.checklist_name', name: checklist.name)) %>
<%=t 'projects.reports.elements.step_checklist.user_time', timestamp: l(timestamp, format: :full) %> diff --git a/app/views/reports/elements/_step_element.html.erb b/app/views/reports/elements/_step_element.html.erb index 633469ca4..ced4d19f4 100644 --- a/app/views/reports/elements/_step_element.html.erb +++ b/app/views/reports/elements/_step_element.html.erb @@ -27,7 +27,7 @@
<% if strip_tags(step.description).present? %> - <%= custom_auto_link(step.description) %> + <%= custom_auto_link(step.description, false) %> <% else %> <%=t "projects.reports.elements.step.no_description" %> <% end %> diff --git a/app/views/results/_result_text.html.erb b/app/views/results/_result_text.html.erb index efd098b81..aa93123f2 100644 --- a/app/views/results/_result_text.html.erb +++ b/app/views/results/_result_text.html.erb @@ -1,3 +1,3 @@
- <%= custom_auto_link(result.result_text.text) %> + <%= custom_auto_link(result.result_text.text, false) %>
diff --git a/app/views/steps/_step.html.erb b/app/views/steps/_step.html.erb index 8b6747174..cc362fdd3 100644 --- a/app/views/steps/_step.html.erb +++ b/app/views/steps/_step.html.erb @@ -37,7 +37,7 @@ <%= t("protocols.steps.no_description") %> <% else %>
- <%= custom_auto_link(step.description) %> + <%= custom_auto_link(step.description, false) %>
<% end %>