Drupal Atom module spits invalid xml

Drupal Atom module is spitting invalid XML in some cases. It is obvious that all user generated text in XML should be either escaped or appear within CDATA section. However it is not the case with title and subtitle sections. If the site title contains “&”, then the atom/feed will guaranteed to be invalid.

I came across this the hard way, in one of the sites I was maintaining someone decided that they need “&” in the title, then the atom/feed was giving a XML parser error. After little bit of head scratching, I was able to triangulate the buggy piece of code.

You can read the progress of the issue at http://drupal.org/node/229392, you can download the patch from the same.

Hope I saved someone from much head scratching and frustrations.