Fix RTE images in exports [SCI-9164] (#6095)

This commit is contained in:
artoscinote 2023-08-29 13:50:43 +02:00 committed by GitHub
parent c955c235d2
commit 30cb9b0697
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View file

@ -4,8 +4,8 @@ require 'sanitize'
require 'cgi'
module InputSanitizeHelper
def sanitize_input(html, _tags = [], _attributes = [])
Sanitize.fragment(html, Constants::INPUT_SANITIZE_CONFIG).html_safe
def sanitize_input(html, _tags = [], _attributes = [], sanitizer_config: Constants::INPUT_SANITIZE_CONFIG)
Sanitize.fragment(html, sanitizer_config).html_safe
end
def escape_input(text)
@ -25,7 +25,12 @@ module InputSanitizeHelper
format_opt = wrapper_tag.merge(sanitize: false)
base64_encoded_imgs = options.fetch(:base64_encoded_imgs, false)
text = simple_format(text, {}, format_opt) if simple_f
text = sanitize_input(text, tags)
# allow base64 images when sanitizing if base64_encoded_imgs is true
sanitizer_config = Constants::INPUT_SANITIZE_CONFIG.deep_dup
sanitizer_config[:protocols]['img']['src'] << 'data' if options.fetch(:base64_encoded_imgs, false)
text = sanitize_input(text, tags, sanitizer_config: sanitizer_config)
if text =~ SmartAnnotations::TagToHtml::USER_REGEX || text =~ SmartAnnotations::TagToHtml::REGEX
text = smart_annotation_parser(text, team, base64_encoded_imgs, preview_repository)
end

View file

@ -59,7 +59,7 @@
</div>
</div>
<div class="report-element-children">
<%= render partial: 'reports/elements/my_module_protocol_element', locals: { protocol: my_module.protocol } %>
<%= render partial: 'reports/elements/my_module_protocol_element', locals: { protocol: my_module.protocol, export_all: export_all } %>
<% filter_steps_for_report(my_module.protocol.steps, @settings).order(:position).each do |step| %>
<%= render partial: 'reports/elements/my_module_step_element', locals: { step: step, export_all: export_all } %>