Index: wp-includes/feed.php
===================================================================
--- wp-includes/feed.php	(revision 10655)
+++ wp-includes/feed.php	(working copy)
@@ -321,28 +321,47 @@
 	$cat_names = array();
 
 	$filter = 'rss';
-	if ( 'atom' == $type )
+
+	if ( 'atom' == $type ) {
+		global $wp_rewrite;
 		$filter = 'raw';
+		$url = apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) );
+		$permastruct['category'] = $wp_rewrite->get_category_permastruct();
+		$permastruct['tag'] = $wp_rewrite->get_tag_permastruct();
+		foreach ( array('category' => 'categories', 'tag' => 'tags') as $taxonomy => $var ) {
+			if ( $permastructs[$taxonomy] )
+				$permastruct = str_replace( "%$taxonomy%", '', $permastructs[$taxonomy] );
+			else
+				$permastruct = "/$taxonomy/";
+			$scheme = $url . $permastruct;
+			if ( !empty($$var) ) foreach ( $$var as $term ) {
+				$scheme = sanitize_term_field( 'scheme', $scheme,     $term->term_id, $taxonomy, 'attribute' );
+				$slug   = sanitize_term_field( 'slug',   $term->slug, $term->term_id, $taxonomy, 'attribute' );
+				$label  = sanitize_term_field( 'name',   $term->name, $term->term_id, $taxonomy, 'attribute' );
+				$the_list .= "\n\t\t" . sprintf( '<category scheme="%1$s" term="%2$s" label="%3$s" />', $scheme, $slug, $label);
+			}
+		}
+	} else {
+		if ( !empty($categories) ) foreach ( (array) $categories as $category ) {
+			$cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter);
+		}
 
-	if ( !empty($categories) ) foreach ( (array) $categories as $category ) {
-		$cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter);
-	}
+		if ( !empty($tags) ) foreach ( (array) $tags as $tag ) {
+			$cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter);
+		}
 
-	if ( !empty($tags) ) foreach ( (array) $tags as $tag ) {
-		$cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter);
+		$cat_names = array_unique($cat_names);
+
+		foreach ( $cat_names as $cat_name ) {
+			if ( 'rdf' == $type )
+				$the_list .= "\n\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n";
+			else
+				$the_list .= "\n\t\t<category><![CDATA[" . html_entity_decode( $cat_name ) . "]]></category>\n";
+		}
 	}
 
-	$cat_names = array_unique($cat_names);
+	$the_list = trim($the_list) . "\n";
 
-	foreach ( $cat_names as $cat_name ) {
-		if ( 'rdf' == $type )
-			$the_list .= "\n\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n";
-		elseif ( 'atom' == $type )
-			$the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', attribute_escape( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), attribute_escape( $cat_name ) );
-		else
-			$the_list .= "\n\t\t<category><![CDATA[" . html_entity_decode( $cat_name ) . "]]></category>\n";
-	}
-
 	return apply_filters('the_category_rss', $the_list, $type);
 }
 
