Fixing Serendipity Atom Feeds

I have another blog, less technical than this one, which runs Serendipity. I was upgrading to the latest version (a task long neglected) when I noticed that my Atom feeds weren't producing valid XML. The problem was caused by some URLs which had ampersands in them, the Atom feed wasn't encoding them as & like the RSS versions. A bit of digging around, comparing the Atom templates with the RSS ones, and I uncovered the problem - in the files templates/default/feed_atom1.0.tpl and templates/default/feed_atom0.3.tpl find the line:

{$entry.feed_body} {$entry.feed_ext}

And change it to:

{$entry.feed_body|@escape} {$entry.feed_ext|@escape}

It's somewhere around line 50. After that, characters are escaped correctly in the Atom feeds.