Index: wp-includes/template-functions-general.php
===================================================================
--- wp-includes/template-functions-general.php	(revision 3397)
+++ wp-includes/template-functions-general.php	(working copy)
@@ -82,6 +82,15 @@
 		case 'wpurl' :
 			$output = get_settings('siteurl');
 			break;
+		case 'atom_alternate_url':
+		case 'self' :
+			$output = get_settings('siteurl');
+			$cat = '';
+			$feed = str_replace('_self', '', $feed);
+			$cat = intval( get_query_var('cat') );
+			if ( ( $cat != 0 ) && ( strtoupper($cat) != 'ALL' ) )
+		   		$output .= '?cat=' . $cat;
+			break;
 		case 'description':
 			$output = get_settings('blogdescription');
 			break;
@@ -97,6 +106,9 @@
 		case 'atom_url':
 			$output = get_feed_link('atom');
 			break;
+		case 'atom_self_url':
+			$output = get_feed_link('atom_self');
+			break;
 		case 'comments_rss2_url':
 			$output = get_feed_link('comments_rss2');
 			break;
Index: wp-includes/template-functions-links.php
===================================================================
--- wp-includes/template-functions-links.php	(revision 3397)
+++ wp-includes/template-functions-links.php	(working copy)
@@ -180,6 +180,13 @@
 	$do_perma = 0;
 	$feed_url = get_settings('siteurl');
 	$comment_feed_url = $feed_url;
+	$cat = '';
+	if ( false !== strpos($feed, '_self') ) {
+		$feed = str_replace('_self', '', $feed);
+		$cat = intval( get_query_var('cat') );
+		if ( ( $cat == 0 ) || ( strtoupper($cat) == 'ALL' ) )
+	   		$cat = '';
+	}
 
 	$permalink = $wp_rewrite->get_feed_permastruct();
 	if ( '' != $permalink ) {
@@ -197,8 +204,10 @@
 	} else {
 		if ( false !== strpos($feed, 'comments_') )
 			$feed = str_replace('comments_', 'comments-', $feed);
+		if ( $cat )
+			$cat = "&cat={$cat}";
 
-		$output = get_settings('home') . "/?feed={$feed}";
+		$output = get_settings('home') . "/?feed={$feed}{$cat}";
 	}
 
 	return apply_filters('feed_link', $output, $feed);
Index: wp-includes/feed-functions.php
===================================================================
--- wp-includes/feed-functions.php	(revision 3397)
+++ wp-includes/feed-functions.php	(working copy)
@@ -105,7 +105,7 @@
 				 $link = get_author_link(0, $author_id, $author_nicename);
 				 $link = $link . "feed/";
        }
-			 
+
 			 $link = apply_filters('author_feed_link', $link);
 
        if ($echo) echo $link;
@@ -148,7 +148,7 @@
 
 	$custom_fields = get_post_custom();
 	if( is_array( $custom_fields ) ) {
-		while( list( $key, $val ) = each( $custom_fields ) ) { 
+		while( list( $key, $val ) = each( $custom_fields ) ) {
 			if( $key == 'enclosure' ) {
 				if (is_array($val)) {
 					foreach($val as $enc) {
@@ -161,4 +161,23 @@
 	}
 }
 
+
+function atom_enclosure() {
+	global $id, $post;
+	if (!empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password)) return;
+
+	$custom_fields = get_post_custom();
+	if( is_array( $custom_fields ) ) {
+	while( list( $key, $val ) = each( $custom_fields ) ) {
+			if( $key == 'enclosure' ) {
+				if (is_array($val)) {
+					foreach($val as $enc) {
+						$enclosure = split( "\n", $enc );
+						print "<link rel=\"enclosure\" href=\"".trim( htmlspecialchars($enclosure[ 0 ]) )."\" length=\"".trim( $enclosure[ 1 ] )."\" type=\"".trim( $enclosure[ 2 ] )."\"/>\n";
+					}
+				}
+			}
+		}
+	}
+}
 ?>
\ No newline at end of file
Index: wp-content/themes/classic/header.php
===================================================================
--- wp-content/themes/classic/header.php	(revision 3397)
+++ wp-content/themes/classic/header.php	(working copy)
@@ -14,7 +14,7 @@
 
 	<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
 	<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
-	<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
+	<link rel="alternate" type="application/atom+xml" title="Atom 1.0" href="<?php bloginfo('atom_url'); ?>" />
 	
 	<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
     <?php wp_get_archives('type=monthly&format=link'); ?>
Index: wp-content/themes/default/header.php
===================================================================
--- wp-content/themes/default/header.php	(revision 3397)
+++ wp-content/themes/default/header.php	(working copy)
@@ -9,6 +9,7 @@
 <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats -->
 
 <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
+<link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" />
 <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
 <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
 
Index: wp-atom.php
===================================================================
--- wp-atom.php	(revision 3397)
+++ wp-atom.php	(working copy)
@@ -1,45 +1,59 @@
 <?php
+// Atom 1.0 feed generator for WordPress
+// Distributed under the terms of the GNU General Public License v2
 
-if (empty($wp)) {
-	require_once('wp-config.php');
-	wp('feed=atom');
+if (empty($feed)) {
+	$blog = 1;
+	$feed = 'atom';
+	$doing_rss = 1;
+	require('wp-blog-header.php');
 }
 
 header('Content-type: application/atom+xml; charset=' . get_settings('blog_charset'), true);
 $more = 1;
-
 ?>
-<?php echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'; ?>
-<feed version="0.3"
-  xmlns="http://purl.org/atom/ns#"
-  xmlns:dc="http://purl.org/dc/elements/1.1/"
-  xml:lang="<?php echo get_option('rss_language'); ?>"
-  <?php do_action('atom_ns'); ?>
-  >
-	<title><?php bloginfo_rss('name') ?></title>
-	<link rel="alternate" type="text/html" href="<?php bloginfo_rss('home') ?>" />
-	<tagline><?php bloginfo_rss("description") ?></tagline>
-	<modified><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></modified>
-	<copyright>Copyright <?php echo mysql2date('Y', get_lastpostdate('blog'), 0); ?></copyright>
-	<generator url="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress</generator>
+<?php echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'."\n"; ?>
+<feed xmlns="http://www.w3.org/2005/Atom"
+      xml:lang="<?php echo get_option('rss_language'); ?>"
+      <?php do_action('atom_ns'); ?>>
+	<title><?php bloginfo_rss('name'); ?></title>
+	<subtitle><?php bloginfo_rss('description'); ?></subtitle>
+	<id><?php bloginfo('url'); ?>/</id>
+	<link rel="self" type="application/atom+xml" href="<?php bloginfo_rss('atom_self_url'); ?>"/>
+	<link rel="alternate" type="<?php bloginfo('html_type'); ?>" href="<?php bloginfo_rss('atom_alternate_url'); ?>"/>
+	<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></updated>
+	<rights>Copyright <?php echo mysql2date('Y', get_lastpostdate('blog'), 0); ?></rights>
+	<generator uri="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress</generator>
 	<?php do_action('atom_head'); ?>
 	<?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
 	<entry>
 	  	<author>
-			<name><?php the_author() ?></name>
+			<name><?php the_author(); ?></name>
 		</author>
-		<title type="text/html" mode="escaped"><![CDATA[<?php the_title_rss() ?>]]></title>
-		<link rel="alternate" type="text/html" href="<?php permalink_single_rss() ?>" />
-		<id><?php the_guid(); ?></id>
-		<modified><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></modified>
-		<issued><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></issued>
-		<?php the_category_rss('rdf') ?> 
-		<summary type="text/plain" mode="escaped"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary>
+		<title type="html"><![CDATA[ <?php the_title_rss(); ?> ]]></title>
+		<link rel="alternate" type="<?php bloginfo('html_type'); ?>" href="<?php permalink_single_rss(); ?>"/>
+		<id><?php permalink_single_rss(); ?></id>
+		<published><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></published>
+		<updated><?php echo mysql2date('Y-m-d\TH:i:s\Z',$post->post_modified_gmt); ?></updated>
+<?php
+	$categories_path = get_category_link(0);
+	$categories = get_the_category();
+	foreach ($categories as $cat) { ?>
+		<category scheme="<?php echo $categories_path; ?>"
+		          term="<?php $foo = "/" . str_replace('/','\/',$categories_path) . "/";
+							echo preg_replace($foo,'',get_category_link($cat->cat_ID)); ?>"
+		          label="<?php echo $cat->cat_name; ?>"/>
+<?php } ?>
+		<summary type="html">
+			<![CDATA[ <?php the_excerpt_rss(); ?> ]]>
+		</summary>
 <?php if ( !get_settings('rss_use_excerpt') ) : ?>
-		<content type="<?php bloginfo('html_type'); ?>" mode="escaped" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content>
+		<content type="html">
+			<![CDATA[ <?php the_content('', 0, '') ?> ]]>
+		</content>
+		<?php atom_enclosure(); ?>
+		<?php do_action('atom_entry'); ?>
 <?php endif; ?>
-<?php rss_enclosure(); ?>
-<?php do_action('atom_entry'); ?>
 	</entry>
 	<?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?>
-</feed>
+</feed>
\ No newline at end of file
