]> cat aescling's git repositories - mastodon.git/commitdiff
Also disallow entities inside of `<code>`
authorkibigo! <go@kibi.family>
Fri, 11 Nov 2022 03:14:52 +0000 (19:14 -0800)
committerkibigo! <go@kibi.family>
Fri, 11 Nov 2022 10:11:12 +0000 (02:11 -0800)
I think this is generally expected behaviour, and people are annoyed
when their code gets turned into links/hashtags/mentions.

app/lib/advanced_text_formatter.rb

index 573639514bf801a124d60f94bf704a44e2d5722c..ba6a5e868921e6e8e241901ee6f48559cb797720 100644 (file)
@@ -71,7 +71,7 @@ class AdvancedTextFormatter < TextFormatter
       Sanitize.node!(@tree, Sanitize::Config::MASTODON_OUTGOING)
       document = @tree.document
 
-      @tree.xpath('.//text()[not(ancestor::a)]').each do |text_node|
+      @tree.xpath('.//text()[not(ancestor::a | ancestor::code)]').each do |text_node|
         # Iterate over text elements and build up their replacements.
         content = text_node.content
         replacement = Nokogiri::XML::NodeSet.new(document)