Unintended blank lines in plugins break XML for feeds
|Reported by:||bchecketts||Owned by:||MarkJaquith|
|Severity:||normal||Keywords:||has-patch tested dev-feedback|
A plugin or theme file may unintentionally output blank lines. When displaying an RSS feed, this breaks XML validation of the page.
To recreate, simply create and activate a plugin that has an extra blank line after the closing ?> characters in the file.
Google Chrome displays this error. Other browsers display something similar:
error on line 4 at column 6: XML declaration allowed only at the start of the document
Although technically a problem with the plugin, Wordpress can easily be modified to discard the undesired output by calling ob_clean() prior to outputting the XML. It seems that ob_start() is already called earlier, so ob_clean() discards any output since that call.
For example, in the default configuration, you can add this line in wp-includes/feed-rss2.php just above the header() function call (in about line 7)
The top of wp-includes/feed-rss2.php now looks like this:
<?php /** * RSS2 Feed Template for displaying RSS2 Posts feed. * * @package WordPress */ ob_clean(); header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true); $more = 1;
Change History (27)
- Component changed from Feeds to Plugins
- Keywords has-patch needs-testing added
- Owner set to westi
- Priority changed from low to normal
- Owner changed from westi to MarkJaquith
- Status changed from new to assigned
- Keywords tested added; needs-testing removed
- Resolution set to fixed
- Status changed from assigned to closed
- Resolution fixed deleted
- Status changed from closed to reopened