mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 01:35:34 +08:00
Fix RTE images in exports [SCI-9164] (#6095)
This commit is contained in:
parent
c955c235d2
commit
30cb9b0697
2 changed files with 9 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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 } %>
|
||||
|
|
Loading…
Reference in a new issue