Index: bb-templates/kakumei/rss2.php
===================================================================
--- bb-templates/kakumei/rss2.php       (revision 2418)
+++ bb-templates/kakumei/rss2.php       (working copy)
@@ -6,30 +6,29 @@
 <rss version="2.0"
        xmlns:content="http://purl.org/rss/1.0/modules/content/"
        xmlns:dc="http://purl.org/dc/elements/1.1/"
-       xmlns:atom="http://www.w3.org/2005/Atom">
+       xmlns:atom="http://www.w3.org/2005/Atom"
+       <?php do_action( 'bb_rss2_ns'); ?>
+       >
        <channel>
                <title><?php echo $title; ?></title>
                <link><?php echo $link; ?></link>
-               <description><![CDATA[<?php echo $description; ?>]]></description>
-               <language><?php esc_html( bb_option('language') ); ?></language>
-               <pubDate><?php echo gmdate('D, d M Y H:i:s +0000'); ?></pubDate>
+               <description><?php echo $description; ?></description>
+               <language><?php echo esc_html( bb_get_option( 'language' ) ); ?></language>
+               <pubDate><?php echo gmdate( 'D, d M Y H:i:s +0000' ); ?></pubDate>
                <?php bb_generator( 'rss2' ); ?>
-               <textInput>
-                       <title><![CDATA[<?php _e('Search'); ?>]]></title>
-                       <description><![CDATA[<?php _e('Search all topics from these forums.'); ?>]]></description>
-                       <name>q</name>
-                       <link><?php bb_uri('search.php'); ?></link>
-               </textInput>
+               <?php do_action( 'bb_rss2_head' ); ?>
                <atom:link href="<?php echo $link_self; ?>" rel="self" type="application/rss+xml" />

-<?php foreach ($posts as $bb_post) : ?>
+<?php foreach ( (array) $posts as $bb_post ) : ?>
                <item>
-                       <title><?php post_author(); ?> <?php _e('on')?> "<?php topic_title( $bb_post->topic_id ); ?>"</title>
+                       <title><?php post_author(); ?> <?php _e( 'on' ); ?> "<?php topic_title( $bb_post->topic_id ); ?>"</title>
                        <link><?php post_link(); ?></link>
-                       <pubDate><?php bb_post_time('D, d M Y H:i:s +0000', array( 'localize' => false ) ); ?></pubDate>
+                       <pubDate><?php bb_post_time( 'D, d M Y H:i:s +0000', array( 'localize' => false ) ); ?></pubDate>
                        <dc:creator><?php post_author(); ?></dc:creator>
                        <guid isPermaLink="false"><?php post_id(); ?>@<?php bb_uri(); ?></guid>
-                       <description><?php post_text(); ?></description>
+                       <description><?php post_text_rss(); ?></description>
+                       <content:encoded><![CDATA[<?php post_text_rss(); ?>]]></content:encoded>
+                       <?php do_action( 'bb_rss2_item' ); ?>
                </item>
 <?php endforeach; ?>

Index: bb-includes/defaults.bb-filters.php
===================================================================
--- bb-includes/defaults.bb-filters.php (revision 2418)
+++ bb-includes/defaults.bb-filters.php (working copy)
@@ -115,11 +115,18 @@
 function bb_filter_feed_content()
 {
        if ( bb_is_feed() ) {
-               add_filter( 'bb_title_rss', 'ent2ncr' );
-               add_filter( 'topic_title', 'ent2ncr' );
+               add_filter( 'bb_title_rss', 'strip_tags' );
+               add_filter( 'bb_title_rss', 'ent2ncr', 8 );
+               add_filter( 'bb_title_rss', 'esc_html' );
+
+               add_filter( 'bb_description_rss', 'strip_tags' );
+               add_filter( 'bb_description_rss', 'ent2ncr', 8 );
+               add_filter( 'bb_description_rss', 'esc_html' );
+
+               add_filter( 'post_author', 'ent2ncr', 8 );
                add_filter( 'post_link', 'esc_html' );
-               add_filter( 'post_text', 'htmlspecialchars' ); // encode_bad should not be overruled by esc_html
-               add_filter( 'post_text', 'ent2ncr' );
+               add_filter( 'post_text_rss', 'ent2ncr', 8 );
+               add_filter( 'post_text_rss', 'esc_html' );
        }
 }
 add_action( 'bb_init', 'bb_filter_feed_content' );
Index: bb-includes/functions.bb-template.php
===================================================================
--- bb-includes/functions.bb-template.php       (revision 2419)
+++ bb-includes/functions.bb-template.php       (working copy)
@@ -1785,6 +1785,10 @@
        }
 }

+function post_text_rss( $post_id = 0 ) {
+       echo apply_filters( 'post_text_rss', get_post_text( $post_id ), get_post_id( $post_id ) );
+}
+
 function post_text( $post_id = 0 ) {
        echo apply_filters( 'post_text', get_post_text( $post_id ), get_post_id( $post_id ) );
 }
Index: rss.php
===================================================================
--- rss.php     (revision 2418)
+++ rss.php     (working copy)
@@ -73,15 +73,13 @@
                                die();

                        $topics = $topics_object->results;
-                       if ( !$topics || !is_array($topics) )
-                               die();

                        $posts = array();
-                       foreach ($topics as $topic) {
+                       foreach ( (array) $topics as $topic ) {
                                $posts[] = bb_get_first_post($topic->topic_id);
                        }

-                       $title = esc_html( sprintf( __( '%1$s &raquo; View: %2$s' ), bb_get_option( 'name' ), $bb_views[$feed_id]['title'] ) );
+                       $title = sprintf( __( '%1$s &raquo; View: %2$s' ), bb_get_option( 'name' ), $bb_views[$feed_id]['title'] );
                        $link = get_view_link($feed_id);
                        $link_self = bb_get_view_rss_link($feed_id);
                        break;
@@ -90,41 +88,41 @@
                        if ( !$topic = get_topic ( $feed_id ) )
                                die();
                        if ( !$posts = get_thread( $feed_id, 0, 1 ) )
-                               die();
-                       $title = esc_html( sprintf( __( '%1$s &raquo; Topic: %2$s' ), bb_get_option( 'name' ), get_topic_title() ) );
+                               die(); /* Should die here, as the topic posts aren't there, so the topic is most probably deleted/empty */
+                       $title = sprintf( __( '%1$s &raquo; Topic: %2$s' ), bb_get_option( 'name' ), get_topic_title() );
                        $link = get_topic_link($feed_id);
                        $link_self = get_topic_rss_link($feed_id);
                        break;

                case 'profile':
-                       if ( bb_get_option( 'mod_rewrite' ) === 'slugs' ) {
-                               $user = bb_get_user_by_nicename( $feed_id );
+                       if ( bb_get_option( 'mod_rewrite' ) === 'slugs') {
+                               if ( !$user = bb_get_user_by_nicename( $feed_id ) )
+                                       $user = bb_get_user( $feed_id );
                        } else {
-                               $user = bb_get_user( $feed_id );
+                               if ( !$user = bb_get_user( $feed_id ) )
+                                       $user = bb_get_user_by_nicename( $feed_id );
                        }
                        if ( !$user ) {
                                die();
                        }
-                       if ( !$posts = get_user_favorites( $user->ID ) ) {
-                               die();
-                       }
-                       $title = esc_html( sprintf( __( '%1$s &raquo; User Favorites: %2$s' ), bb_get_option( 'name' ), $user->user_nicename ) );
-                       $link = bb_get_profile_link($feed_id);
+                       $posts = get_user_favorites( $user->ID );
+
+                       $title = sprintf( __( '%1$s &raquo; User Favorites: %2$s' ), bb_get_option( 'name' ), $user->user_nicename );
+                       $link = get_user_profile_link($feed_id);
                        $link_self = get_favorites_rss_link($feed_id);
                        break;

                case 'tag-topics':
                        if ( !$tag = bb_get_tag( $feed_id ) )
                                die();
-                       if ( !$topics = get_tagged_topics( array( 'tag_id' => $tag->tag_id, 'page' => 0 ) ) )
-                               die();
+                       $topics = get_tagged_topics( array( 'tag_id' => $tag->tag_id, 'page' => 0 ) );

                        $posts = array();
-                       foreach ($topics as $topic) {
+                       foreach ( (array) $topics as $topic ) {
                                $posts[] = bb_get_first_post($topic->topic_id);
                        }

-                       $title = esc_html( sprintf( __( '%1$s &raquo; Tag: %2$s - Recent Topics' ), bb_get_option( 'name' ), bb_get_tag_name() ) );
+                       $title = sprintf( __( '%1$s &raquo; Tag: %2$s - Recent Topics' ), bb_get_option( 'name' ), bb_get_tag_name() );
                        $link = bb_get_tag_link($feed_id);
                        $link_self = bb_get_tag_topics_rss_link($feed_id);
                        break;
@@ -132,46 +130,42 @@
                case 'tag-posts':
                        if ( !$tag = bb_get_tag( $feed_id ) )
                                die();
-                       if ( !$posts = get_tagged_topic_posts( array( 'tag_id' => $tag->tag_id, 'page' => 0 ) ) )
-                               die();
-                       $title = esc_html( sprintf( __( '%1$s &raquo; Tag: %2$s - Recent Posts' ), bb_get_option( 'name' ), bb_get_tag_name() ) );
+                       $posts = get_tagged_topic_posts( array( 'tag_id' => $tag->tag_id, 'page' => 0 ) );
+                       $title = sprintf( __( '%1$s &raquo; Tag: %2$s - Recent Posts' ), bb_get_option( 'name' ), bb_get_tag_name() );
                        $link = bb_get_tag_link($feed_id);
                        $link_self = bb_get_tag_posts_rss_link($feed_id);
                        break;

                case 'forum-topics':
-                       if ( !$topics = get_latest_topics( $feed_id ) )
-                               die();
+                       $topics = get_latest_topics( $feed_id );

                        $posts = array();
-                       foreach ($topics as $topic) {
+                       foreach ( (array) $topics as $topic) {
                                $posts[] = bb_get_first_post($topic->topic_id);
                        }

-                       $title = esc_html( sprintf( __( '%1$s &raquo; Forum: %2$s - Recent Topics' ), bb_get_option( 'name' ), get_forum_name( $feed_id ) ) );
+                       $title = sprintf( __( '%1$s &raquo; Forum: %2$s - Recent Topics' ), bb_get_option( 'name' ), get_forum_name( $feed_id ) );
                        $link = get_forum_link($feed_id);
                        $link_self = bb_get_forum_topics_rss_link($feed_id);
                        break;

                case 'forum-posts':
-                       if ( !$posts = bb_get_latest_forum_posts( $feed_id ) )
-                               die();
-                       $title = esc_html( sprintf( __( '%1$s &raquo; Forum: %2$s - Recent Posts' ), bb_get_option( 'name' ), get_forum_name( $feed_id ) ) );
+                       $posts = bb_get_latest_forum_posts( $feed_id );
+                       $title = sprintf( __( '%1$s &raquo; Forum: %2$s - Recent Posts' ), bb_get_option( 'name' ), get_forum_name( $feed_id ) );
                        $link = get_forum_link($feed_id);
                        $link_self = bb_get_forum_posts_rss_link($feed_id);
                        break;

                // Get just the first post from the latest topics
                case 'all-topics':
-                       if ( !$topics = get_latest_topics() )
-                               die();
+                       $topics = get_latest_topics();

                        $posts = array();
-                       foreach ($topics as $topic) {
+                       foreach ( (array) $topics as $topic ) {
                                $posts[] = bb_get_first_post($topic->topic_id);
                        }

-                       $title = esc_html( sprintf( __( '%1$s &raquo; Recent Topics' ), bb_get_option( 'name' ) ) );
+                       $title = sprintf( __( '%1$s &raquo; Recent Topics' ), bb_get_option( 'name' ) );
                        $link = bb_get_uri();
                        $link_self = bb_get_topics_rss_link();
                        break;
@@ -179,18 +173,20 @@
                // Get latest posts by default
                case 'all-posts':
                default:
-                       if ( !$posts = bb_get_latest_posts( 35 ) )
-                               die();
-                       $title = esc_html( sprintf( __( '%1$s &raquo; Recent Posts' ), bb_get_option( 'name' ) ) );
+                       $posts = bb_get_latest_posts( 35 );
+                       $title = sprintf( __( '%1$s &raquo; Recent Posts' ), bb_get_option( 'name' ) );
                        $link = bb_get_uri();
                        $link_self = bb_get_posts_rss_link();
                        break;
        }
 }

-bb_send_304( $posts[0]->post_time );
+if ( !$posts ) /* We do typecasting in the template, but all themes don't have that! */
+       $posts = array();
+else /* Only send 304 if there are posts */
+       bb_send_304( $posts[0]->post_time );

-if (!$description = esc_html( bb_get_option('description') )) {
+if (!$description = bb_get_option( 'description' ) ) {
        $description = $title;
 }
 $title = apply_filters( 'bb_title_rss', $title, $feed );

