Allow links and images on legislation drafts

Note we're using a new sanitizer. Ideally we'd reuse the
`AdminWYSIWYGSanitizer`, but then code that would be correctly shown by
markdown-it (like the <h1> tag) wouldn't be shown on the web, which is
confusing. Ideally we would configure markdown-it to only allow the tags
present in the `AdminWYSIWYGSanitizer` and provide some kind of help
showing which tags are allowed.
This commit is contained in:
Julian Herrero
2020-07-25 12:42:19 +07:00
committed by Javi Martín
parent b2a07121e3
commit 151aa6009d
4 changed files with 17 additions and 5 deletions

View File

@@ -25,7 +25,7 @@ module ApplicationHelper
superscript: true
}
sanitize(Redcarpet::Markdown.new(renderer, extensions).render(text))
AdminLegislationSanitizer.new.sanitize(Redcarpet::Markdown.new(renderer, extensions).render(text))
end
def wysiwyg(text)

View File

@@ -57,7 +57,7 @@
<div data-sticky-container>
<div data-sticky data-anchor="sticky-panel" class="draft-index sticky" data-tree-navigator>
<%= sanitize(@draft_version.toc_html) %>
<%= AdminLegislationSanitizer.new.sanitize(@draft_version.toc_html) %>
</div>
</div>
</div>
@@ -74,7 +74,7 @@
data-legislation-annotatable-base-url="<%= legislation_process_draft_version_path(@process, @draft_version) %>"
data-legislation-open-phase="<%= @process.allegations_phase.open? %>">
<% end %>
<%= sanitize(@draft_version.body_html, { attributes: ["id"] }) %>
<%= AdminLegislationSanitizer.new.sanitize(@draft_version.body_html) %>
</section>
</div>
</div>