Outputting RSS CDATA As HTML In XSLT Stylesheets Doesn't Work In Firefox
Introduction
I just added an RSS feed to my site1. It's at:
https://www.alanwsmith.com/feeds/posts/xml
I decided to add an XSLT stylesheet2 to make it look prettier for folks who browse to it directly. Everything worked great until I got to the content of the pages.
Handling Escaping
I publish full posts in the feed. Since that can include code snippets and other various things that look like XML I use CDATA
3 to wrap the contents. It's a quick way to make sure the XML in the RSS feed is valid.
By default, the output of the CDATA is escaped. So, instead of getting HTML that works, you get text that looks like this:
<h1>An Example Title</h1>
You can fix that by adding disable-output-escaping="yes"
to the element your outputting. For example:
<xsl:value-of
select="description"
disable-output-escaping="yes"
/>
So Close...
It works great in Chrome and Safari.
Firefox? Not so much. It doesn't have any effect.
Someone filed a bug with Mozilla about the issue4. The bug page doesn't show the exact date. It just says "24 years ago". The last update was 2 days ago, but I'm not optimistic.
For now, I'm just yoinking the contents of the posts and showing on the time in the XSLT view. The full contents will still be availble in the feed that RSS readys use. So, not that big a deal but a bit of a bummer.
Endnotes
-
I could change the way I store the data in the files and escape things myself instead of using CDATA. Not really worth it at this point.
Footnotes
Or, more to the point, added it back in. I've had them on and off over the years. It's been a while since the last time, though.
Also known as "XSL" which comes in a .xsl
file