I like to help people. It’s what I do on a daily basis whether it’s explaining the way I found a bug or teaching someone to play the piano. So when I saw Jay’s tweet about how her RSS feed wasn’t working for her site, I figured the least I could do was ask if I could be of assistance. I think I was at least. It’s fixed now. A 2 hour phone conversation happened where we both were going through our own wordpress installs looking for a way to fix the following error:
End tag ‘script’ does not match the start tag ‘description’.
Line:58 Character: 4</script>
Ironically IE was the most helpful browser because all the other browsers either displayed broken XML or in Firefox’s case it just showed a blank feed. What happened was that she is using the Disqus platform on her blog and that plugin has the option to display the number of comments on a given post right underneath the post title. Problem is that XML’s CDATA tag doesn’t handle Multiple CDATA end tags very well. Here’s the Problem area (then I’ll explain what happened). Sorry for the lack of indents.
<description><![CDATA[
<script type="text/javascript">
// <![CDATA[
(function() {
var links = document.getElementsByTagName('a');
var query = '&';
for(var i = 0; i < links.length; i++) {
if(links[i].href.indexOf(‘#disqus_thread’) >= 0) {
links[i].innerHTML = ‘View Comments’;
query += ‘wpid’ + i + ‘=’ + encodeURIComponent(links[i].getAttribute(‘wpid’)) + ‘&’;
}
}
document.write(‘<script charset=”utf-8″ type=”text/javascript” src=”
<?php echo DISQUS_URL ?>/forums/<?php echo strtolower(get_option
(‘disqus_forum_url’)); ?>/get_num_replies_from_wpid.js?v=2.0′ + query + ‘”>
<’ + ‘/script>’);
})();
//]]>
</script>
The root element here was <description> and since the CDATA technically ended inside the <script> tags the </script> tag was left hanging. This is what caused the feed readers to be confused. There wasn’t a </description> tag to end this, but even worse was that adding an additional ]]> after </script> didn’t fix it. This is why. According to w3schools.com:
Notes on CDATA sections:
A CDATA section cannot contain the string “]]>”. Nested CDATA sections are not allowed.
The “]]>” that marks the end of the CDATA section cannot contain spaces or line breaks.
XML parsers don’t care if you properly markup your javascript, if it see’s “]]>” in the file it’s going to end that CDATA section. So, the fix for all this would be for the Disqus plugin to handle all the population of data outside of the xml.
If you are using the Disqus plugin on your blog and are having the same issue, but want to continue having the number of comments underneath your post title within you posts you should do the following in the disqus.php file of the plugin:
function dsq_comment_count() {
global $dsq_cc_script_embedded;if ( $dsq_cc_script_embedded ) {
return;
} else if ( (is_single() || is_page() || $withcomments || is_feed()) ) {
return;
}
That should take care of the feed issues. However, until Disqus fixes this issue in their plugin, everytime you upgrade, you’ll have to make the change. I have submitted a bug.
See Also:









{ 1 comment… read it below or add one }
Great job. I really though I messed something else up and was messing around with loads of different files to figure out what it was. Great walkthrough keep up the good work champ ;o)