From 3a6451c867595fd58998ee1706589b15a69d993b Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 3 Mar 2023 20:19:29 +0100 Subject: Add support for incoming rich text (#23913) --- lib/sanitize_ext/sanitize_config.rb | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/sanitize_ext/sanitize_config.rb b/lib/sanitize_ext/sanitize_config.rb index dc39e9c90..9cc500c36 100644 --- a/lib/sanitize_ext/sanitize_config.rb +++ b/lib/sanitize_ext/sanitize_config.rb @@ -51,29 +51,22 @@ class Sanitize end UNSUPPORTED_ELEMENTS_TRANSFORMER = lambda do |env| - return unless %w(h1 h2 h3 h4 h5 h6 blockquote pre ul ol li).include?(env[:node_name]) + return unless %w(h1 h2 h3 h4 h5 h6).include?(env[:node_name]) current_node = env[:node] - case env[:node_name] - when 'li' - current_node.traverse do |node| - next unless %w(p ul ol li).include?(node.name) - - node.add_next_sibling('
') if node.next_sibling - node.replace(node.children) unless node.text? - end - else - current_node.name = 'p' - end + current_node.name = 'strong' + current_node.wrap('

') end MASTODON_STRICT ||= freeze_config( - elements: %w(p br span a), + elements: %w(p br span a del pre blockquote code b strong u i em ul ol li), attributes: { 'a' => %w(href rel class), 'span' => %w(class), + 'ol' => %w(start reversed), + 'li' => %w(value), }, add_attributes: { -- cgit