miniflux / v2

Minimalist and opinionated feed reader
https://miniflux.app
Apache License 2.0
6.44k stars 702 forks source link

Miniflux reader removes certain `span`s from code blocks #2698

Open JohnnyJayJay opened 1 week ago

JohnnyJayJay commented 1 week ago

Miniflux removes certain elements from pre blocks, for some reason.

For example, in one of my posts, I have the following HTML:

<pre><code class="bash hljs language-bash">$ ( <span class="hljs-built_in">set</span> -e; <span class="hljs-literal">false</span>; <span class="hljs-built_in">echo</span> hello ) <span class="hljs-comment"># exit 1</span>
$ <span class="hljs-keyword">if</span> ( <span class="hljs-built_in">set</span> -e; <span class="hljs-literal">false</span>; <span class="hljs-built_in">echo</span> hello ) ; <span class="hljs-keyword">then</span> <span class="hljs-built_in">echo</span> world ; <span class="hljs-keyword">fi</span> <span class="hljs-comment"># exit 0</span>
hello
world
</code></pre>

(This is the highlight.js output for this code block):

$ ( set -e; false; echo hello ) # exit 1
$ if ( set -e; false; echo hello ) ; then echo world ; fi # exit 0
hello
world

I would expect Miniflux to display all text from that pre in its reader. But it doesn't, it removes the spans that use the hljs-comment class, so it ends up looking like this in the reader:

$ ( set -e; false; echo hello ) 
$ if ( set -e; false; echo hello ) ; then echo world ; fi 
hello
world

Is this intended behaviour? If not, why could this be? What part of the code filters out spans with that class?

I'm running Miniflux via docker-compose, latest image tag (I pulled the latest version right before writing this).

fguillot commented 1 week ago

The sanitizer doesn't preserve the <div> and <span> elements. However, the # exit 1 should not have been removed. That needs to be investigated.

JohnnyJayJay commented 6 days ago

The sanitiser is not responsible - I tested it when creating my recent PR. Something else removes the text in those spans (either before, or after calling Sanitize)