[wp-trac] [WordPress Trac] #12089: Unintended blank lines in plugins break XML for feeds

WordPress Trac wp-trac at lists.automattic.com
Sat Jan 30 19:23:57 UTC 2010


#12089: Unintended blank lines in plugins break XML for feeds
--------------------------+-------------------------------------------------
 Reporter:  bchecketts    |       Owner:            
     Type:  defect (bug)  |      Status:  new       
 Priority:  low           |   Milestone:  Unassigned
Component:  Feeds         |     Version:            
 Severity:  normal        |    Keywords:            
--------------------------+-------------------------------------------------
 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)

 ob_clean();

 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;
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/12089>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list