Index: wp-login.php
===================================================================
--- wp-login.php	(.../2.0.6)	(revision 5177)
+++ wp-login.php	(.../2.0.10)	(revision 5177)
@@ -166,7 +166,7 @@
 	$user_login = '';
 	$user_pass = '';
 	$using_cookie = false;
-	if ( !isset( $_REQUEST['redirect_to'] ) )
+	if ( !isset( $_REQUEST['redirect_to'] ) || is_user_logged_in() )
 		$redirect_to = 'wp-admin/';
 	else
 		$redirect_to = $_REQUEST['redirect_to'];
Index: wp-comments-post.php
===================================================================
--- wp-comments-post.php	(.../2.0.6)	(revision 5177)
+++ wp-comments-post.php	(.../2.0.10)	(revision 5177)
@@ -25,14 +25,20 @@
 
 // If the user is logged in
 $user = wp_get_current_user();
-if ( $user->ID ) :
+if ( $user->ID ) {
 	$comment_author       = $wpdb->escape($user->display_name);
 	$comment_author_email = $wpdb->escape($user->user_email);
 	$comment_author_url   = $wpdb->escape($user->user_url);
-else :
+	if ( current_user_can('unfiltered_html') ) {
+		if ( wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $_POST['_wp_unfiltered_html_comment'] ) {
+			kses_remove_filters(); // start with a clean slate
+			kses_init_filters(); // set up the filters
+		}
+	}
+} else {
 	if ( get_option('comment_registration') )
 		die( __('Sorry, you must be logged in to post a comment.') );
-endif;
+}
 
 $comment_type = '';
 
Index: wp-includes/default-filters.php
===================================================================
--- wp-includes/default-filters.php	(.../2.0.6)	(revision 5177)
+++ wp-includes/default-filters.php	(.../2.0.10)	(revision 5177)
@@ -33,6 +33,8 @@
 add_filter('pre_comment_author_email', 'wp_filter_kses');
 add_filter('pre_comment_author_url', 'wp_filter_kses');
 
+add_action('comment_form', 'wp_comment_form_unfiltered_html_nonce');
+
 // Default filters for these functions
 add_filter('comment_author', 'wptexturize');
 add_filter('comment_author', 'convert_chars');
Index: wp-includes/template-functions-general.php
===================================================================
--- wp-includes/template-functions-general.php	(.../2.0.6)	(revision 5177)
+++ wp-includes/template-functions-general.php	(.../2.0.10)	(revision 5177)
@@ -137,8 +137,7 @@
 
 
 function wp_title($sep = '&raquo;', $display = true) {
-	global $wpdb;
-	global $m, $year, $monthnum, $day, $category_name, $month, $posts;
+	global $wpdb, $posts, $month;
 
 	$cat = get_query_var('cat');
 	$p = get_query_var('p');
@@ -146,14 +145,18 @@
 	$category_name = get_query_var('category_name');
 	$author = get_query_var('author');
 	$author_name = get_query_var('author_name');
+	$m = (int) get_query_var('m');
+	$year = (int) get_query_var('year');
+	$monthnum = (int) get_query_var('monthnum');
+	$day = (int) get_query_var('day');
+	$title = '';
 
 	// If there's a category
 	if ( !empty($cat) ) {
 			// category exclusion
 			if ( !stristr($cat,'-') )
-				$title = get_the_category_by_ID($cat);
-	}
-	if ( !empty($category_name) ) {
+				$title = apply_filters('single_cat_title', get_the_category_by_ID($cat));
+	} elseif ( !empty($category_name) ) {
 		if ( stristr($category_name,'/') ) {
 				$category_name = explode('/',$category_name);
 				if ( $category_name[count($category_name)-1] )
@@ -162,6 +165,7 @@
 					$category_name = $category_name[count($category_name)-2]; // there was a trailling slash
 		}
 		$title = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE category_nicename = '$category_name'");
+		$title = apply_filters('single_cat_title', $title);
 	}
 
 	// If there's an author
@@ -196,7 +200,7 @@
 	}
 
 	$prefix = '';
-	if ( isset($title) )
+	if ( !empty($title) )
 		$prefix = " $sep ";
 
 	$title = $prefix . $title;
@@ -244,7 +248,12 @@
 
 
 function single_month_title($prefix = '', $display = true ) {
-	global $m, $monthnum, $month, $year;
+	global $month;
+
+	$m = (int) get_query_var('m');
+	$year = (int) get_query_var('year');
+	$monthnum = (int) get_query_var('monthnum');
+
 	if ( !empty($monthnum) && !empty($year) ) {
 		$my_year = $year;
 		$my_month = $month[str_pad($monthnum, 2, '0', STR_PAD_LEFT)];
Index: wp-includes/template-functions-category.php
===================================================================
--- wp-includes/template-functions-category.php	(.../2.0.6)	(revision 5177)
+++ wp-includes/template-functions-category.php	(.../2.0.10)	(revision 5177)
@@ -3,8 +3,9 @@
 function get_the_category($id = false) {
 global $post, $category_cache;
 
+	$id = (int) $id;
 	if ( !$id )
-		$id = $post->ID;
+		$id = (int) $post->ID;
 
 	if ( !isset($category_cache[$id]) )
 		update_post_category_cache($id);
Index: wp-includes/cache.php
===================================================================
--- wp-includes/cache.php	(.../2.0.6)	(revision 5177)
+++ wp-includes/cache.php	(.../2.0.10)	(revision 5177)
@@ -8,6 +8,8 @@
 function wp_cache_close() {
 	global $wp_object_cache;
 
+	if ( ! isset($wp_object_cache) )
+		return;
 	return $wp_object_cache->save();
 }
 
@@ -402,8 +404,14 @@
 	}
 
 	function WP_Object_Cache() {
+		return $this->__construct();
+	}
+	
+	function __construct() {
 		global $blog_id;
 
+		register_shutdown_function(array(&$this, "__destruct"));
+
 		if (defined('DISABLE_CACHE'))
 			return;
 
@@ -438,5 +446,10 @@
 
 		$this->blog_id = $this->hash($blog_id);
 	}
+
+	function __destruct() {
+		$this->save();
+		return true;	
+	}
 }
 ?>
Index: wp-includes/wp-db.php
===================================================================
--- wp-includes/wp-db.php	(.../2.0.6)	(revision 5177)
+++ wp-includes/wp-db.php	(.../2.0.10)	(revision 5177)
@@ -40,6 +40,12 @@
 	//	DB Constructor - connects to the server and selects a database
 
 	function wpdb($dbuser, $dbpassword, $dbname, $dbhost) {
+		return $this->__construct($dbuser, $dbpassword, $dbname, $dbhost);
+	}
+	
+	function __construct($dbuser, $dbpassword, $dbname, $dbhost) {
+		register_shutdown_function(array(&$this, "__destruct"));
+
 		$this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword);
 		if (!$this->dbh) {
 			$this->bail("
@@ -57,6 +63,10 @@
 		$this->select($dbname);
 	}
 
+	function __destruct() {
+		return true;		
+	}
+
 	// ==================================================================
 	//	Select a DB (if another one needs to be selected)
 
Index: wp-includes/links.php
===================================================================
--- wp-includes/links.php	(.../2.0.6)	(revision 5177)
+++ wp-includes/links.php	(.../2.0.10)	(revision 5177)
@@ -212,7 +212,7 @@
 
 		$the_link = '#';
 		if (!empty($row->link_url))
-			$the_link = attribute_escape($row->link_url);
+			$the_link = clean_url($row->link_url);
 
 		$rel = $row->link_rel;
 		if ($rel != '') {
Index: wp-includes/functions-formatting.php
===================================================================
--- wp-includes/functions-formatting.php	(.../2.0.6)	(revision 5177)
+++ wp-includes/functions-formatting.php	(.../2.0.10)	(revision 5177)
@@ -1051,7 +1051,11 @@
 	$strip = array('%0d', '%0a');
 	$url = str_replace($strip, '', $url);
 	$url = str_replace(';//', '://', $url);
-	$url = (!strstr($url, '://')) ? 'http://'.$url : $url;
+	// Append http unless a relative link starting with / or a php file.
+	if ( strpos($url, '://') === false &&
+		substr( $url, 0, 1 ) != '/' && !preg_match('/^[a-z0-9]+?\.php/i', $url) )
+		$url = 'http://' . $url;
+	
 	$url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&#038;$1', $url);
 	if ( !is_array($protocols) )
 		$protocols = array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet'); 
Index: wp-includes/version.php
===================================================================
--- wp-includes/version.php	(.../2.0.6)	(revision 5177)
+++ wp-includes/version.php	(.../2.0.10)	(revision 5177)
@@ -2,7 +2,7 @@
 
 // This just holds the version number, in a separate file so we can bump it without cluttering the SVN
 
-$wp_version = '2.0.6';
+$wp_version = '2.0.10';
 $wp_db_version = 3441;
 
 ?>
Index: wp-includes/js/tinymce/wp-mce-help.php
===================================================================
--- wp-includes/js/tinymce/wp-mce-help.php	(.../2.0.6)	(revision 5177)
+++ wp-includes/js/tinymce/wp-mce-help.php	(.../2.0.10)	(revision 5177)
@@ -1,6 +1,7 @@
 <?php
 
 require_once('../../../wp-config.php');
+header('Content-Type: text/html; charset='.get_bloginfo('charset'));
 
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Index: wp-includes/js/tinymce/tiny_mce_gzip.php
===================================================================
--- wp-includes/js/tinymce/tiny_mce_gzip.php	(.../2.0.6)	(revision 5177)
+++ wp-includes/js/tinymce/tiny_mce_gzip.php	(.../2.0.10)	(revision 5177)
@@ -59,7 +59,7 @@
 	gzip_compression();
 
 	// Output rest of headers
-	header("Content-type: text/javascript; charset: UTF-8");
+	header("Content-Type: text/javascript; charset=".get_bloginfo('charset'));
 	header("Vary: Accept-Encoding"); // Handle proxies
 	header("Expires: " . gmdate("D, d M Y H:i:s", time() + $expiresOffset) . " GMT");
 
Index: wp-includes/functions-post.php
===================================================================
--- wp-includes/functions-post.php	(.../2.0.6)	(revision 5177)
+++ wp-includes/functions-post.php	(.../2.0.10)	(revision 5177)
@@ -47,7 +47,7 @@
 	
 	// Get the post ID.
 	if ( $update )
-		$post_ID = $ID;
+		$post_ID = (int) $ID;
 
 	// Create a valid post name.  Drafts are allowed to have an empty
 	// post name.
@@ -406,6 +406,7 @@
 	global $wpdb;
 
 	// Set the limit clause, if we got a limit
+	$num = (int) $num;
 	if ($num) {
 		$limit = "LIMIT $num";
 	}
@@ -476,6 +477,9 @@
 
 function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) {
 	global $wpdb;
+	
+	$post_ID = (int) $post_ID;
+
 	// If $post_categories isn't already an array, make it one:
 	if (!is_array($post_categories) || 0 == count($post_categories))
 		$post_categories = array(get_option('default_category'));
@@ -486,7 +490,7 @@
 	$old_categories = $wpdb->get_col("
 		SELECT category_id 
 		FROM $wpdb->post2cat 
-		WHERE post_id = $post_ID");
+		WHERE post_id = '$post_ID'");
 	
 	if (!$old_categories) {
 		$old_categories = array();
@@ -501,8 +505,8 @@
 		foreach ($delete_cats as $del) {
 			$wpdb->query("
 				DELETE FROM $wpdb->post2cat 
-				WHERE category_id = $del 
-					AND post_id = $post_ID 
+				WHERE category_id = '$del' 
+					AND post_id = '$post_ID' 
 				");
 		}
 	}
@@ -512,12 +516,14 @@
 
 	if ($add_cats) {
 		foreach ($add_cats as $new_cat) {
-			$wpdb->query("
-				INSERT INTO $wpdb->post2cat (post_id, category_id) 
-				VALUES ($post_ID, $new_cat)");
+			$new_cat = (int) $new_cat;
+			if ( !empty($new_cat) )
+				$wpdb->query("
+					INSERT INTO $wpdb->post2cat (post_id, category_id) 
+					VALUES ('$post_ID', '$new_cat')");
 		}
 	}
-	
+
 	// Update category counts.
 	$all_affected_cats = array_unique(array_merge($post_categories, $old_categories));
 	foreach ( $all_affected_cats as $cat_id ) {
Index: wp-includes/classes.php
===================================================================
--- wp-includes/classes.php	(.../2.0.6)	(revision 5177)
+++ wp-includes/classes.php	(.../2.0.10)	(revision 5177)
@@ -1319,7 +1319,15 @@
 		if (empty($this->permalink_structure)) {
 			return $rewrite;
 		}
+		//Default Feed rules - These are require to allow for the direct access files to work with permalink structure starting with %category%
+		$default_feeds = array(	'wp-atom.php$'	=>	$this->index .'?feed=atom',
+								'wp-rdf.php$'	=>	$this->index .'?feed=rdf',
+								'wp-rss.php$'	=>	$this->index .'?feed=rss',
+								'wp-rss2.php$'	=>	$this->index .'?feed=rss2',
+								'wp-feed.php$'	=>	$this->index .'?feed=feed',
+								'wp-commentsrss2.php$'	=>	$this->index . '?feed=rss2&withcomments=1');
 
+
 		// Post
 		$post_rewrite = $this->generate_rewrite_rules($this->permalink_structure);
 		$post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite);
@@ -1354,7 +1362,7 @@
 		$page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
 
 		// Put them together.
-		$this->rules = array_merge($page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $author_rewrite, $date_rewrite, $post_rewrite);
+		$this->rules = array_merge($default_feeds, $page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $author_rewrite, $date_rewrite, $post_rewrite);
 
 		do_action('generate_rewrite_rules', array(&$this));
 		$this->rules = apply_filters('rewrite_rules_array', $this->rules);
@@ -1609,6 +1617,9 @@
 				$this->query_vars[$wpvar] = $query_vars[$wpvar];
 			else
 				$this->query_vars[$wpvar] = '';
+
+			if ( !empty( $this->query_vars[$wpvar] ) )
+				$this->query_vars[$wpvar] = (string) $this->query_vars[$wpvar];
 		}
 
 		if ( isset($error) )
@@ -1637,7 +1648,8 @@
 			@header("ETag: $wp_etag");
 
 			// Support for Conditional GET
-			if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']);
+			if (isset($_SERVER['HTTP_IF_NONE_MATCH']))
+				$client_etag = stripslashes(stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
 			else $client_etag = false;
 
 			$client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE']);
@@ -1662,6 +1674,8 @@
 		foreach ($this->public_query_vars as $wpvar) {
 			if (isset($this->query_vars[$wpvar]) && '' != $this->query_vars[$wpvar]) {
 				$this->query_string .= (strlen($this->query_string) < 1) ? '' : '&';
+				if ( !is_scalar($this->query_vars[$wpvar]) ) // Discard non-scalars.
+					continue;
 				$this->query_string .= $wpvar . '=' . rawurlencode($this->query_vars[$wpvar]);
 			}
 		}
Index: wp-includes/template-functions-links.php
===================================================================
--- wp-includes/template-functions-links.php	(.../2.0.6)	(revision 5177)
+++ wp-includes/template-functions-links.php	(.../2.0.10)	(revision 5177)
@@ -87,8 +87,9 @@
 function get_page_link($id = false) {
 	global $post, $wp_rewrite;
 
+	$id = (int) $id;
 	if ( !$id )
-		$id = $post->ID;
+		$id = (int) $post->ID;
 
 	$pagestruct = $wp_rewrite->get_page_permastruct();
 
@@ -109,7 +110,7 @@
 	$link = false;
 
 	if (! $id) {
-		$id = $post->ID;
+		$id = (int) $post->ID;
 	}
 
 	$object = get_post($id);
@@ -378,7 +379,7 @@
 function get_pagenum_link($pagenum = 1) {
 	global $wp_rewrite;
 
-	$qstr = wp_specialchars($_SERVER['REQUEST_URI']);
+	$qstr = $_SERVER['REQUEST_URI'];
 
 	$page_querystring = "paged"; 
 	$page_modstring = "page/";
@@ -445,7 +446,7 @@
 	return $qstr;
 }
 
-function next_posts($max_page = 0) { // original by cfactor at cooltux.org
+function get_next_posts_page_link($max_page = 0) {
 	global $paged, $pagenow;
 
 	if ( !is_single() ) {
@@ -453,10 +454,14 @@
 			$paged = 1;
 		$nextpage = intval($paged) + 1;
 		if ( !$max_page || $max_page >= $nextpage )
-			echo get_pagenum_link($nextpage);
+			return get_pagenum_link($nextpage);
 	}
 }
 
+function next_posts($max_page = 0) {
+	echo clean_url(get_next_posts_page_link($max_page));
+}
+
 function next_posts_link($label='Next Page &raquo;', $max_page=0) {
 	global $paged, $result, $request, $posts_per_page, $wpdb, $max_num_pages;
 	if ( !$max_page ) {
@@ -479,18 +484,20 @@
 	}
 }
 
-
-function previous_posts() { // original by cfactor at cooltux.org
+function get_previous_posts_page_link() {
 	global $paged, $pagenow;
 
 	if ( !is_single() ) {
 		$nextpage = intval($paged) - 1;
 		if ( $nextpage < 1 )
 			$nextpage = 1;
-		echo get_pagenum_link($nextpage);
+		return get_pagenum_link($nextpage);
 	}
 }
 
+function previous_posts() {
+	echo clean_url(get_previous_posts_page_link());
+}
 
 function previous_posts_link($label='&laquo; Previous Page') {
 	global $paged;
Index: wp-includes/pluggable-functions.php
===================================================================
--- wp-includes/pluggable-functions.php	(.../2.0.6)	(revision 5177)
+++ wp-includes/pluggable-functions.php	(.../2.0.10)	(revision 5177)
@@ -466,7 +466,7 @@
 if ( !function_exists('wp_verify_nonce') ) :
 function wp_verify_nonce($nonce, $action = -1) {
 	$user = wp_get_current_user();
-	$uid = $user->id;
+	$uid = (int) $user->id;
 
 	$i = ceil(time() / 43200);
 
@@ -480,7 +480,7 @@
 if ( !function_exists('wp_create_nonce') ) :
 function wp_create_nonce($action = -1) {
 	$user = wp_get_current_user();
-	$uid = $user->id;
+	$uid = (int) $user->id;
 
 	$i = ceil(time() / 43200);
 	
Index: wp-includes/comment-functions.php
===================================================================
--- wp-includes/comment-functions.php	(.../2.0.6)	(revision 5177)
+++ wp-includes/comment-functions.php	(.../2.0.10)	(revision 5177)
@@ -2,6 +2,12 @@
 
 // Template functions
 
+function wp_comment_form_unfiltered_html_nonce() {
+	global $post;
+	if ( current_user_can('unfiltered_html') )
+		wp_nonce_field('unfiltered-html-comment_' . $post->ID, '_wp_unfiltered_html_comment', false);
+}
+
 function comments_template( $file = '/comments.php' ) {
 	global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity;
 
@@ -84,7 +90,7 @@
 	('$comment_post_ID', '$comment_author', '$comment_author_email', '$comment_author_url', '$comment_author_IP', '$comment_date', '$comment_date_gmt', '$comment_content', '$comment_approved', '$comment_agent', '$comment_type', '$comment_parent', '$user_id')
 	");
 
-	$id = $wpdb->insert_id;
+	$id = (int) $wpdb->insert_id;
 
 	if ( $comment_approved == 1) {
 		$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'");
@@ -218,7 +224,7 @@
 	$post_id = (int) $post_id;
 
 	if ( !$post_id )
-		$post_id = $id;
+		$post_id = (int) $id;
 
 	if ( !isset($comment_count_cache[$post_id]) )
 		$comment_count_cache[$id] = $wpdb->get_var("SELECT comment_count FROM $wpdb->posts WHERE ID = '$post_id'");
Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(.../2.0.6)	(revision 5177)
+++ wp-includes/functions.php	(.../2.0.10)	(revision 5177)
@@ -171,6 +171,7 @@
 
 function get_usernumposts($userid) {
 	global $wpdb;
+	$userid = (int) $userid;
 	return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$userid' AND post_status = 'publish'");
 }
 
@@ -606,6 +607,7 @@
 			$post_cache[$post->ID] = &$post;
 		$_post = & $post_cache[$post->ID];
 	} else {
+		$post = (int) $post;
 		if ( $_post = wp_cache_get($post, 'pages') )
 			return get_page($_post, $output);
 		elseif ( isset($post_cache[$post]) )
@@ -709,6 +711,7 @@
 		wp_cache_add($page->ID, $page, 'pages');
 		$_page = $page;
 	} else {
+		$page = (int) $page;
 		if ( isset($GLOBALS['page']) && ($page == $GLOBALS['page']->ID) ) {
 			$_page = & $GLOBALS['page'];
 			wp_cache_add($_page->ID, $_page, 'pages');
@@ -767,6 +770,7 @@
 		wp_cache_add($category->cat_ID, $category, 'category');
 		$_category = $category;
 	} else {
+		$category = (int) $category;
 		if ( ! $_category = wp_cache_get($category, 'category') ) {
 			$_category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$category' LIMIT 1");
 			wp_cache_add($category, $_category, 'category');
@@ -804,6 +808,7 @@
 			$comment_cache[$comment->comment_ID] = &$comment;
 		$_comment = & $comment_cache[$comment->comment_ID];
 	} else {
+		$comment = (int) $comment;
 		if ( !isset($comment_cache[$comment]) ) {
 			$_comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment' LIMIT 1");
 			$comment_cache[$comment->comment_ID] = & $_comment;
@@ -2019,7 +2024,7 @@
 function get_page_template() {
 	global $wp_query;
 
-	$id = $wp_query->post->ID;
+	$id = (int) $wp_query->post->ID;
 	$template = get_post_meta($id, '_wp_page_template', true);
 
 	if ( 'default' == $template )
@@ -2167,7 +2172,8 @@
 	global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query,
 		$wp_rewrite, $wpdb;
 
-	extract($wp_query->query_vars, EXTR_SKIP);
+	if ( is_array($wp_query->query_vars) )
+		extract($wp_query->query_vars, EXTR_SKIP);
 
 	require_once($_template_file);
 }
@@ -2186,10 +2192,21 @@
 }
 
 function wp_remote_fopen( $uri ) {
+	$timeout = 10;
+	$parsed_url = @parse_url($uri);
+
+	if ( !$parsed_url || !is_array($parsed_url) )
+		return false;
+
+	if ( !isset($parsed_url['scheme']) || !in_array($parsed_url['scheme'], array('http','https')) )
+		$uri = 'http://' . $uri;
+
 	if ( ini_get('allow_url_fopen') ) {
 		$fp = @fopen( $uri, 'r' );
 		if ( !$fp )
 			return false;
+
+		//stream_set_timeout($fp, $timeout); // Requires php 4.3
 		$linea = '';
 		while( $remote_read = fread($fp, 4096) )
 			$linea .= $remote_read;
@@ -2200,6 +2217,7 @@
 		curl_setopt ($handle, CURLOPT_URL, $uri);
 		curl_setopt ($handle, CURLOPT_CONNECTTIMEOUT, 1);
 		curl_setopt ($handle, CURLOPT_RETURNTRANSFER, 1);
+		curl_setopt ($handle, CURLOPT_TIMEOUT, $timeout);
 		$buffer = curl_exec($handle);
 		curl_close($handle);
 		return $buffer;
@@ -2228,10 +2246,10 @@
 	elseif ( 410 == $header )
 		$text = 'Gone';
 
-		if ( substr(php_sapi_name(), 0, 3) == 'cgi' )
-			@header("HTTP/1.1 $header $text");
-		else
-			@header("Status: $header $text");
+	if ( version_compare(phpversion(), '4.3.0', '>=') )
+		@header("HTTP/1.1 $header $text", true, $header);
+	else
+		@header("HTTP/1.1 $header $text");
 }
 
 function nocache_headers() {
@@ -2356,9 +2374,11 @@
 	return wp_specialchars(add_query_arg('_wpnonce', wp_create_nonce($action), $actionurl));
 }
 
-function wp_nonce_field($action = -1) {
-	echo '<input type="hidden" name="_wpnonce" value="' . wp_create_nonce($action) . '" />';
-	wp_referer_field();
+function wp_nonce_field($action = -1, $name = "_wpnonce", $referer = true) {
+	$name = attribute_escape($name);
+	echo '<input type="hidden" name="' . $name . '" value="' . wp_create_nonce($action) . '" />';
+	if ( $referer )
+		wp_referer_field();
 }
 
 function wp_referer_field() {
@@ -2471,9 +2491,9 @@
 			$html .= "\t\t<input type='hidden' name='" . attribute_escape( urldecode($k)) . "' value='" . attribute_escape( urldecode($v)) . "' />\n";
 		}
 		$html .= "\t\t<input type='hidden' name='_wpnonce' value='" . wp_create_nonce($action) . "' />\n";
-		$html .= "\t\t<div id='message' class='confirm fade'>\n\t\t<p>" . wp_explain_nonce($action) . "</p>\n\t\t<p><a href='$adminurl'>" . __('No') . "</a> <input type='submit' value='" . __('Yes') . "' /></p>\n\t\t</div>\n\t</form>\n";
+		$html .= "\t\t<div id='message' class='confirm fade'>\n\t\t<p>" . wp_specialchars(wp_explain_nonce($action)) . "</p>\n\t\t<p><a href='$adminurl'>" . __('No') . "</a> <input type='submit' value='" . __('Yes') . "' /></p>\n\t\t</div>\n\t</form>\n";
 	} else {
-		$html .= "\t<div id='message' class='confirm fade'>\n\t<p>" . wp_explain_nonce($action) . "</p>\n\t<p><a href='$adminurl'>" . __('No') . "</a> <a href='" . attribute_escape(add_query_arg('_wpnonce', wp_create_nonce($action), $_SERVER['REQUEST_URI'])) . "'>" . __('Yes') . "</a></p>\n\t</div>\n";
+		$html .= "\t<div id='message' class='confirm fade'>\n\t<p>" . wp_specialchars(wp_explain_nonce($action)) . "</p>\n\t<p><a href='$adminurl'>" . __('No') . "</a> <a href='" . clean_url(add_query_arg('_wpnonce', wp_create_nonce($action), $_SERVER['REQUEST_URI'])) . "'>" . __('Yes') . "</a></p>\n\t</div>\n";
 	}
 	$html .= "</body>\n</html>";
 	wp_die($html, $title);
Index: wp-includes/rss-functions.php
===================================================================
--- wp-includes/rss-functions.php	(.../2.0.6)	(revision 5177)
+++ wp-includes/rss-functions.php	(.../2.0.10)	(revision 5177)
@@ -816,9 +816,8 @@
 		return -1;
 	}
 	}
-function wp_rss ($url, $num) {
+function wp_rss ($url, $num_items) {
 	//ini_set("display_errors", false); uncomment to suppress php errors thrown if the feed is not returned.
-	$num_items = $num;
 	$rss = fetch_rss($url);
 		if ( $rss ) {
 			echo "<ul>";
@@ -837,7 +836,7 @@
 	}
 }
 
-function get_rss ($uri, $num = 5) { // Like get posts, but for RSS
+function get_rss ($url, $num_items = 5) { // Like get posts, but for RSS
 	$rss = fetch_rss($url);
 	if ( $rss ) {
 		$rss->items = array_slice($rss->items, 0, $num_items);
@@ -848,7 +847,6 @@
 			echo "</a><br />\n";
 			echo "</li>\n";
 		}
-		return $posts;
 	} else {
 		return false;
 	}
Index: wp-includes/registration-functions.php
===================================================================
--- wp-includes/registration-functions.php	(.../2.0.6)	(revision 5177)
+++ wp-includes/registration-functions.php	(.../2.0.10)	(revision 5177)
@@ -77,7 +77,7 @@
 		$query = "UPDATE $wpdb->users SET user_pass='$user_pass', user_email='$user_email', user_url='$user_url', user_nicename = '$user_nicename', display_name = '$display_name' WHERE ID = '$ID'";
 		$query = apply_filters('update_user_query', $query);
 		$wpdb->query( $query );
-		$user_id = $ID;
+		$user_id = (int) $ID;
 	} else {
 		$query = "INSERT INTO $wpdb->users 
 		(user_login, user_pass, user_email, user_url, user_registered, user_nicename, display_name)
@@ -85,7 +85,7 @@
 		('$user_login', '$user_pass', '$user_email', '$user_url', '$user_registered', '$user_nicename', '$display_name')";
 		$query = apply_filters('create_user_query', $query);
 		$wpdb->query( $query );
-		$user_id = $wpdb->insert_id;
+		$user_id = (int) $wpdb->insert_id;
 	}
 	
 	update_usermeta( $user_id, 'first_name', $first_name);
Index: wp-includes/template-functions-author.php
===================================================================
--- wp-includes/template-functions-author.php	(.../2.0.6)	(revision 5177)
+++ wp-includes/template-functions-author.php	(.../2.0.10)	(revision 5177)
@@ -136,7 +136,7 @@
 
 function get_author_link($echo = false, $author_id, $author_nicename = '') {
 	global $wpdb, $wp_rewrite, $post, $cache_userdata;
-	$auth_ID = $author_id;
+	$auth_ID = (int) $author_id;
 	$link = $wp_rewrite->get_author_permastruct();
 
 	if ( empty($link) ) {
Index: xmlrpc.php
===================================================================
--- xmlrpc.php	(.../2.0.6)	(revision 5177)
+++ xmlrpc.php	(.../2.0.10)	(revision 5177)
@@ -208,9 +208,9 @@
 
 		$this->escape($args);
 
-	  $post_ID    = $args[1];
-	  $user_login = $args[2];
-	  $user_pass  = $args[3];
+		$post_ID    = (int) $args[1];
+		$user_login = $args[2];
+		$user_pass  = $args[3];
 
 	  if (!$this->login_pass_ok($user_login, $user_pass)) {
 	    return $this->error;
@@ -243,10 +243,10 @@
 
 		$this->escape($args);
 
-	  $blog_ID    = $args[1]; /* though we don't use it yet */
-	  $user_login = $args[2];
-	  $user_pass  = $args[3];
-	  $num_posts  = $args[4];
+		$blog_ID    = (int) $args[1]; /* though we don't use it yet */
+		$user_login = $args[2];
+		$user_pass  = $args[3];
+		$num_posts  = $args[4];
 
 	  if (!$this->login_pass_ok($user_login, $user_pass)) {
 	    return $this->error;
@@ -291,7 +291,7 @@
 
 		$this->escape($args);
 
-	  $blog_ID    = $args[1];
+	  $blog_ID    = (int) $args[1];
 	  $user_login = $args[2];
 	  $user_pass  = $args[3];
 	  $template   = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */
@@ -325,7 +325,7 @@
 
 		$this->escape($args);
 
-	  $blog_ID    = $args[1];
+	  $blog_ID    = (int) $args[1];
 	  $user_login = $args[2];
 	  $user_pass  = $args[3];
 	  $content    = $args[4];
@@ -362,7 +362,7 @@
 
 		$this->escape($args);
 
-	  $blog_ID    = $args[1]; /* though we don't use it yet */
+	  $blog_ID    = (int) $args[1]; /* though we don't use it yet */
 	  $user_login = $args[2];
 	  $user_pass  = $args[3];
 	  $content    = $args[4];
@@ -409,7 +409,7 @@
 
 		$this->escape($args);
 
-	  $post_ID     = $args[1];
+	  $post_ID     = (int) $args[1];
 	  $user_login  = $args[2];
 	  $user_pass   = $args[3];
 	  $content     = $args[4];
@@ -433,6 +433,9 @@
 
 	  extract($actual_post);
 
+	  if ( ('publish' == $post_status) && !current_user_can('publish_posts') )
+	  	return new IXR_Error(401, 'Sorry, you do not have the right to publish this post.');
+
 	  $post_title = xmlrpc_getposttitle($content);
 	  $post_category = xmlrpc_getpostcategory($content);
 	  $post_content = xmlrpc_removepostdata($content);
@@ -456,7 +459,7 @@
 
 		$this->escape($args);
 
-	  $post_ID     = $args[1];
+	  $post_ID     = (int) $args[1];
 	  $user_login  = $args[2];
 	  $user_pass   = $args[3];
 	  $publish     = $args[4];
@@ -497,7 +500,7 @@
 
 		$this->escape($args);
 
-	  $blog_ID     = $args[0]; // we will support this in the near future
+	  $blog_ID     = (int) $args[0]; // we will support this in the near future
 	  $user_login  = $args[1];
 	  $user_pass   = $args[2];
 	  $content_struct = $args[3];
@@ -532,7 +535,9 @@
 	    $post_content = $post_content . "\n<!--more-->\n" . $post_more;
 	  }
 
-		$to_ping = $content_struct['mt_tb_ping_urls'];
+	  $to_ping = $content_struct['mt_tb_ping_urls'];
+	  if ( is_array($to_ping) )
+	  	$to_ping = implode(' ', $to_ping);
 
 	  // Do some timestamp voodoo
 	  $dateCreatedd = $content_struct['dateCreated'];
@@ -577,7 +582,7 @@
 
 		$this->escape($args);
 
-	  $post_ID     = $args[0];
+	  $post_ID     = (int) $args[0];
 	  $user_login  = $args[1];
 	  $user_pass   = $args[2];
 	  $content_struct = $args[3];
@@ -611,12 +616,18 @@
 	  $post_more = $content_struct['mt_text_more'];
 	  $post_status = $publish ? 'publish' : 'draft';
 
+
+	  if ( ('publish' == $post_status) && !current_user_can('publish_posts') )
+	  	return new IXR_Error(401, 'Sorry, you do not have the right to publish this post.');
+
 	  if ($post_more) {
 	    $post_content = $post_content . "\n<!--more-->\n" . $post_more;
 	  }
 
-		$to_ping = $content_struct['mt_tb_ping_urls'];
-
+	  $to_ping = $content_struct['mt_tb_ping_urls'];
+	  if ( is_array($to_ping) )
+	  	$to_ping = implode(' ', $to_ping);
+	  
 	  $comment_status = (empty($content_struct['mt_allow_comments'])) ?
 	    get_settings('default_comment_status')
 	    : $content_struct['mt_allow_comments'];
@@ -657,7 +668,7 @@
 
 		$this->escape($args);
 
-	  $post_ID     = $args[0];
+	  $post_ID     = (int) $args[0];
 	  $user_login  = $args[1];
 	  $user_pass   = $args[2];
 
@@ -712,10 +723,10 @@
 
 		$this->escape($args);
 
-	  $blog_ID     = $args[0];
-	  $user_login  = $args[1];
-	  $user_pass   = $args[2];
-	  $num_posts   = $args[3];
+		$blog_ID     = (int) $args[0];
+		$user_login  = $args[1];
+		$user_pass   = $args[2];
+		$num_posts   = (int) $args[3];
 
 	  if (!$this->login_pass_ok($user_login, $user_pass)) {
 	    return $this->error;
@@ -778,9 +789,9 @@
 
 		$this->escape($args);
 
-	  $blog_ID     = $args[0];
-	  $user_login  = $args[1];
-	  $user_pass   = $args[2];
+		$blog_ID     = (int) $args[0];
+		$user_login  = $args[1];
+		$user_pass   = $args[2];
 
 	  if (!$this->login_pass_ok($user_login, $user_pass)) {
 	    return $this->error;
@@ -812,7 +823,7 @@
 
 		global $wpdb;
 
-		$blog_ID     = $wpdb->escape($args[0]);
+		$blog_ID     = (int) $args[0];
 		$user_login  = $wpdb->escape($args[1]);
 		$user_pass   = $wpdb->escape($args[2]);
 		$data        = $args[3];
@@ -852,10 +863,10 @@
 
 		$this->escape($args);
 
-	  $blog_ID     = $args[0];
-	  $user_login  = $args[1];
-	  $user_pass   = $args[2];
-	  $num_posts   = $args[3];
+		$blog_ID     = (int) $args[0];
+		$user_login  = $args[1];
+		$user_pass   = $args[2];
+		$num_posts   = (int) $args[3];
 
 	  if (!$this->login_pass_ok($user_login, $user_pass)) {
 	    return $this->error;
@@ -897,9 +908,9 @@
 
 		$this->escape($args);
 
-	  $blog_ID     = $args[0];
-	  $user_login  = $args[1];
-	  $user_pass   = $args[2];
+		$blog_ID     = (int) $args[0];
+		$user_login  = $args[1];
+		$user_pass   = $args[2];
 
 	  if (!$this->login_pass_ok($user_login, $user_pass)) {
 	    return $this->error;
@@ -926,9 +937,9 @@
 
 		$this->escape($args);
 
-	  $post_ID     = $args[0];
-	  $user_login  = $args[1];
-	  $user_pass   = $args[2];
+		$post_ID     = (int) $args[0];
+		$user_login  = $args[1];
+		$user_pass   = $args[2];
 
 	  if (!$this->login_pass_ok($user_login, $user_pass)) {
 	    return $this->error;
@@ -956,10 +967,10 @@
 
 		$this->escape($args);
 
-	  $post_ID     = $args[0];
-	  $user_login  = $args[1];
-	  $user_pass   = $args[2];
-	  $categories  = $args[3];
+		$post_ID     = (int) $args[0];
+		$user_login  = $args[1];
+		$user_pass   = $args[2];
+		$categories  = $args[3];
 
 	  if (!$this->login_pass_ok($user_login, $user_pass)) {
 	    return $this->error;
@@ -1039,9 +1050,9 @@
 
 		$this->escape($args);
 
-	  $post_ID     = $args[0];
-	  $user_login  = $args[1];
-	  $user_pass   = $args[2];
+		$post_ID     = (int) $args[0];
+		$user_login  = $args[1];
+		$user_pass   = $args[2];
 
 	  if (!$this->login_pass_ok($user_login, $user_pass)) {
 	    return $this->error;
@@ -1101,18 +1112,18 @@
 		} elseif (preg_match('#p/[0-9]{1,}#', $urltest['path'], $match)) {
 			// the path defines the post_ID (archives/p/XXXX)
 			$blah = explode('/', $match[0]);
-			$post_ID = $blah[1];
+			$post_ID = (int) $blah[1];
 			$way = 'from the path';
 		} elseif (preg_match('#p=[0-9]{1,}#', $urltest['query'], $match)) {
 			// the querystring defines the post_ID (?p=XXXX)
 			$blah = explode('=', $match[0]);
-			$post_ID = $blah[1];
+			$post_ID = (int) $blah[1];
 			$way = 'from the querystring';
 		} elseif (isset($urltest['fragment'])) {
 			// an #anchor is there, it's either...
 			if (intval($urltest['fragment'])) {
 				// ...an integer #XXXX (simpliest case)
-				$post_ID = $urltest['fragment'];
+				$post_ID = (int) $urltest['fragment'];
 				$way = 'from the fragment (numeric)';
 			} elseif (preg_match('/post-[0-9]+/',$urltest['fragment'])) {
 				// ...a post id in the form 'post-###'
Index: wp-trackback.php
===================================================================
--- wp-trackback.php	(.../2.0.6)	(revision 5177)
+++ wp-trackback.php	(.../2.0.10)	(revision 5177)
@@ -84,7 +84,7 @@
 		$title = (strlen($title) > 250) ? substr($title, 0, 250) . '...' : $title;
 	}
 
-	$comment_post_ID = $tb_id;
+	$comment_post_ID = (int) $tb_id;
 	$comment_author = $blog_name;
 	$comment_author_email = '';
 	$comment_author_url = $tb_url;
Index: readme.html
===================================================================
--- readme.html	(.../2.0.6)	(revision 5177)
+++ readme.html	(.../2.0.10)	(revision 5177)
@@ -80,7 +80,7 @@
 	<dt><a href="http://wordpress.org/support/">WordPress Support Forums</a></dt>
 	<dd>If you've looked everywhere and still can't find an answer, the support forums are very active and have a large community ready to help. To help them help you be sure to use a descriptive thread title and describe your question in as much detail as possible. </dd>
 	<dt><a href="http://codex.wordpress.org/IRC">WordPress IRC Channel</a></dt>
-	<dd>Finally, there is an online chat channel that is used for discussion amoung people who use WordPress and occasionally support topics. The above wiki page should point you in the right direction. (irc.freenode.net #wordpresss) </dd>
+	<dd>Finally, there is an online chat channel that is used for discussion among people who use WordPress and occasionally support topics. The above wiki page should point you in the right direction. (irc.freenode.net #wordpress) </dd>
 </dl>
 
 <h1 id="requirements">System Recommendations</h1>
Index: wp-settings.php
===================================================================
--- wp-settings.php	(.../2.0.6)	(revision 5177)
+++ wp-settings.php	(.../2.0.10)	(revision 5177)
@@ -12,8 +12,10 @@
 	
 	$input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
 	foreach ( $input as $k => $v ) 
-		if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) )
+		if ( !in_array($k, $noUnset) && isset($GLOBALS[$k]) ) {
+			$GLOBALS[$k] = NULL;
 			unset($GLOBALS[$k]);
+		}
 }
 
 unregister_GLOBALS(); 
Index: wp-admin/edit-form-advanced.php
===================================================================
--- wp-admin/edit-form-advanced.php	(.../2.0.6)	(revision 5177)
+++ wp-admin/edit-form-advanced.php	(.../2.0.10)	(revision 5177)
@@ -151,7 +151,6 @@
  }
 ?>
 <?php the_quicktags(); ?>
-</fieldset>
 
 <div><textarea <?php if ( user_can_richedit() ) echo 'title="true" '; ?>rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="2" id="content"><?php echo user_can_richedit() ? wp_richedit_pre($post->post_content) : $post->post_content; ?></textarea></div>
 </fieldset>
Index: wp-admin/inline-uploading.php
===================================================================
--- wp-admin/inline-uploading.php	(.../2.0.6)	(revision 5177)
+++ wp-admin/inline-uploading.php	(.../2.0.10)	(revision 5177)
@@ -431,7 +431,7 @@
 function sendToEditor(n) {
 	o = document.getElementById('div'+n);
 	h = o.innerHTML.replace(new RegExp('^\\s*(.*?)\\s*$', ''), '$1'); // Trim
-	h = h.replace(new RegExp(' (class|title|width|height|id|onclick|onmousedown)=([^\'"][^ ]*)( |/|>)', 'g'), ' $1="$2"$3'); // Enclose attribs in quotes
+	h = h.replace(new RegExp(' (class|title|width|height|id|onclick|onmousedown)=([^\'"][^ ]*)(?=( |/|>))', 'g'), ' $1="$2"'); // Enclose attribs in quotes
 	h = h.replace(new RegExp(' (width|height)=".*?"', 'g'), ''); // Drop size constraints
 	h = h.replace(new RegExp(' on(click|mousedown)="[^"]*"', 'g'), ''); // Drop menu events
 	h = h.replace(new RegExp('<(/?)A', 'g'), '<$1a'); // Lowercase tagnames
Index: wp-admin/link-import.php
===================================================================
--- wp-admin/link-import.php	(.../2.0.6)	(revision 5177)
+++ wp-admin/link-import.php	(.../2.0.10)	(revision 5177)
@@ -26,7 +26,7 @@
 <form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll">
 <?php wp_nonce_field('import-bookmarks') ?>
 
-<p><?php _e('If a program or website you use allows you to export your links or subscriptions as OPML you may import them here.'); ?>
+<p><?php _e('If a program or website you use allows you to export your links or subscriptions as OPML you may import them here.'); ?></p>
 <div style="width: 70%; margin: auto; height: 8em;">
 <input type="hidden" name="step" value="1" />
 <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
Index: wp-admin/edit-comments.php
===================================================================
--- wp-admin/edit-comments.php	(.../2.0.6)	(revision 5177)
+++ wp-admin/edit-comments.php	(.../2.0.10)	(revision 5177)
@@ -44,7 +44,7 @@
 	$i = 0;
 	foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
 		$comment = (int) $comment;
-		$post_id = $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
+		$post_id = (int) $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
 		$authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
 		if ( current_user_can('edit_post', $post_id) ) :
 			wp_set_comment_status($comment, "delete");
Index: wp-admin/link-categories.php
===================================================================
--- wp-admin/link-categories.php	(.../2.0.6)	(revision 5177)
+++ wp-admin/link-categories.php	(.../2.0.10)	(revision 5177)
@@ -360,9 +360,10 @@
 				<?php if (1 == $row->cat_id ) { 
 					_e('Default');
 				} else { ?>
-					<a href="<?php echo wp_nonce_url("link-categories.php?cat_id=$row->cat_id?>&amp;action=Delete", 'delete-link-category_' . $row->cat_id) ?>" onclick="return deleteSomething( 'link category', <?php echo $row->cat_id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; link category.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape($row->cat_name)); ?>' );" class="delete"><?php _e('Delete') ?></a></td>
+					<a href="<?php echo wp_nonce_url("link-categories.php?cat_id=$row->cat_id?>&amp;action=Delete", 'delete-link-category_' . $row->cat_id) ?>" onclick="return deleteSomething( 'link category', <?php echo $row->cat_id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; link category.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape($row->cat_name)); ?>' );" class="delete"><?php _e('Delete') ?></a>
 				<?php } ?>
-              </tr>
+              </td>
+	   </tr>
 <?php
         ++$i;
     }
Index: wp-admin/post.php
===================================================================
--- wp-admin/post.php	(.../2.0.6)	(revision 5177)
+++ wp-admin/post.php	(.../2.0.10)	(revision 5177)
@@ -81,7 +81,7 @@
 	?>
 	<div id='preview' class='wrap'>
 	<h2 id="preview-post"><?php _e('Post Preview (updated when post is saved)'); ?> <small class="quickjump"><a href="#write-post"><?php _e('edit &uarr;'); ?></a></small></h2>
-		<iframe src="<?php echo attribute_escape(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" width="100%" height="600" ></iframe>
+		<iframe src="<?php echo clean_url(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" width="100%" height="600" ></iframe>
 	</div>
 	<?php
 	break;
@@ -138,10 +138,13 @@
 
 case 'delete':
 	$post_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']);
-	check_admin_referer('delete-post_' . $post_id);
 
 	$post = & get_post($post_id);
-	
+	if ( 'static' == $post->post_status )
+		check_admin_referer('delete-page_' . $post_id);
+	else
+		check_admin_referer('delete-post_' . $post_id);
+
 	if ( !current_user_can('edit_post', $post_id) )	
 		die( __('You are not allowed to delete this post.') );
 
@@ -154,9 +157,12 @@
 	}
 
 	$sendback = wp_get_referer();
-	if (strstr($sendback, 'post.php')) $sendback = get_settings('siteurl') .'/wp-admin/post.php';
-	elseif (strstr($sendback, 'attachments.php')) $sendback = get_settings('siteurl') .'/wp-admin/attachments.php';
-	$sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
+	if ( 'static' == $post->post_status )
+		$sendback = get_option('siteurl') . '/wp-admin/edit-pages.php';
+	elseif ( strstr($sendback, 'post.php') )
+		$sendback = get_option('siteurl') .'/wp-admin/post.php';
+	elseif ( strstr($sendback, 'attachments.php') )
+		$sendback = get_option('siteurl') .'/wp-admin/attachments.php';
 	wp_redirect($sendback);
 	break;
 
Index: wp-admin/upgrade.php
===================================================================
--- wp-admin/upgrade.php	(.../2.0.6)	(revision 5177)
+++ wp-admin/upgrade.php	(.../2.0.10)	(revision 5177)
@@ -67,7 +67,7 @@
 switch($step) {
 
 	case 0:
-	$goback = attribute_escape(stripslashes(wp_get_referer()));
+	$goback = clean_url(stripslashes(wp_get_referer()));
 ?> 
 <p><?php _e('This file upgrades you from any previous version of WordPress to the latest. It may take a while though, so be patient.'); ?></p> 
 	<h2 class="step"><a href="upgrade.php?step=1&amp;backto=<?php echo $goback; ?>"><?php _e('Upgrade WordPress &raquo;'); ?></a></h2>
@@ -86,7 +86,7 @@
 	if ( empty( $_GET['backto'] ) )
 		$backto = __get_option('home');
 	else
-		$backto = attribute_escape(stripslashes($_GET['backto']));
+		$backto = clean_url(stripslashes($_GET['backto']));
 ?> 
 <h2><?php _e('Step 1'); ?></h2> 
 	<p><?php printf(__("There's actually only one step. So if you see this, you're done. <a href='%s'>Have fun</a>!"),  $backto); ?></p>
Index: wp-admin/admin-functions.php
===================================================================
--- wp-admin/admin-functions.php	(.../2.0.6)	(revision 5177)
+++ wp-admin/admin-functions.php	(.../2.0.10)	(revision 5177)
@@ -289,7 +289,7 @@
 	else if ( !empty($post_title) ) {
 		$text       = wp_specialchars(stripslashes(urldecode($_REQUEST['text'])));
 		$text       = funky_javascript_fix($text);
-		$popupurl   = attribute_escape(stripslashes($_REQUEST['popupurl']));
+		$popupurl   = clean_url(stripslashes($_REQUEST['popupurl']));
         $post_content = '<a href="'.$popupurl.'">'.$post_title.'</a>'."\n$text";
     }
 
@@ -339,7 +339,7 @@
 	$user = new WP_User($user_id);
 	$user->user_login   = attribute_escape($user->user_login);
 	$user->user_email   = attribute_escape($user->user_email);
-	$user->user_url     = attribute_escape($user->user_url);
+	$user->user_url     = clean_url($user->user_url);
 	$user->first_name   = attribute_escape($user->first_name);
 	$user->last_name    = attribute_escape($user->last_name);
 	$user->display_name = attribute_escape($user->display_name);
@@ -363,7 +363,7 @@
 
 	if ($user_id != 0) {
 		$update = true;
-		$user->ID = $user_id;
+		$user->ID = (int) $user_id;
 		$userdata = get_userdata($user_id);
 		$user->user_login = $wpdb->escape($userdata->user_login);
 	} else {
@@ -388,7 +388,7 @@
 	if (isset ($_POST['email']))
 		$user->user_email = wp_specialchars(trim($_POST['email']));
 	if (isset ($_POST['url'])) {
-		$user->user_url = wp_specialchars(trim($_POST['url']));
+		$user->user_url = clean_url(trim($_POST['url']));
 		$user->user_url = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $user->user_url) ? $user->user_url : 'http://'.$user->user_url;
 	}
 	if (isset ($_POST['first_name']))
@@ -467,11 +467,11 @@
 function get_link_to_edit($link_id) {
 	$link = get_link($link_id);
 
-	$link->link_url         = attribute_escape($link->link_url);
+	$link->link_url         =        clean_url($link->link_url);
 	$link->link_name        = attribute_escape($link->link_name);
 	$link->link_image       = attribute_escape($link->link_image);
 	$link->link_description = attribute_escape($link->link_description);
-	$link->link_rss         = attribute_escape($link->link_rss);
+	$link->link_rss         =        clean_url($link->link_rss);
 	$link->link_rel         = attribute_escape($link->link_rel);
 	$link->link_notes       =  wp_specialchars($link->link_notes);
 	$link->post_category    = $link->link_category;
@@ -481,7 +481,7 @@
 
 function get_default_link_to_edit() {
 	if ( isset($_GET['linkurl']) )
-		$link->link_url = attribute_escape($_GET['linkurl']);
+		$link->link_url = clean_url($_GET['linkurl']);
 	else
 		$link->link_url = '';
 	
@@ -502,10 +502,10 @@
 		die(__("Cheatin' uh ?"));
 
 	$_POST['link_url'] = wp_specialchars($_POST['link_url']);
-	$_POST['link_url'] = preg_match('/^(https?|ftps?|mailto|news|gopher):/is', $_POST['link_url']) ? $_POST['link_url'] : 'http://' . $_POST['link_url'];
+	$_POST['link_url'] = clean_url($_POST['link_url']);
 	$_POST['link_name'] = wp_specialchars($_POST['link_name']);
 	$_POST['link_image'] = wp_specialchars($_POST['link_image']);
-	$_POST['link_rss'] = wp_specialchars($_POST['link_rss']);
+	$_POST['link_rss'] = clean_url($_POST['link_rss']);
 	$auto_toggle = get_autotoggle($_POST['link_category']);
 	
 	// if we are in an auto toggle category and this one is visible then we
@@ -866,8 +866,8 @@
 			<tr class='$style'>
 				<td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>
 				<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>
-				<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__('Update')."' /><br />
-				<input name='deletemeta[{$entry['meta_id']}]' type='submit' class='deletemeta' tabindex='6' value='".__('Delete')."' /></td>
+				<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".attribute_escape(__('Update'))."' /><br />
+				<input name='deletemeta[{$entry['meta_id']}]' type='submit' class='deletemeta' tabindex='6' value='".attribute_escape(__('Delete'))."' /></td>
 			</tr>
 		";
 	}
@@ -931,6 +931,7 @@
 
 function add_meta($post_ID) {
 	global $wpdb;
+	$post_ID = (int) $post_ID;
 
 	$metakeyselect = $wpdb->escape(stripslashes(trim($_POST['metakeyselect'])));
 	$metakeyinput = $wpdb->escape(stripslashes(trim($_POST['metakeyinput'])));
@@ -957,6 +958,7 @@
 
 function delete_meta($mid) {
 	global $wpdb;
+	$mid = (int) $mid;
 
 	$result = $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'");
 }
@@ -1810,7 +1812,7 @@
 o.submit();
 }
 </script>
-<form enctype="multipart/form-data" id="uploadForm" method="post" action="<?php echo $action ?>">
+<form enctype="multipart/form-data" id="uploadForm" method="post" action="<?php echo attribute_escape($action) ?>">
 <label for="upload"><?php _e('File:'); ?></label><input type="file" id="upload" name="import" />
 <input type="hidden" name="action" value="save" />
 <div id="buttons">
Index: wp-admin/user-edit.php
===================================================================
--- wp-admin/user-edit.php	(.../2.0.6)	(revision 5177)
+++ wp-admin/user-edit.php	(.../2.0.10)	(revision 5177)
@@ -112,7 +112,7 @@
 <p><label><?php _e('Nickname:') ?><br />
 <input type="text" name="nickname" value="<?php echo $profileuser->nickname ?>" /></label></p>
 
-</p><label><?php _e('Display name publicly as:') ?> <br />
+<p><label><?php _e('Display name publicly as:') ?> <br />
 <select name="display_name">
 <option value="<?php echo $profileuser->display_name; ?>"><?php echo $profileuser->display_name; ?></option>
 <option value="<?php echo $profileuser->nickname ?>"><?php echo $profileuser->nickname ?></option>
Index: wp-admin/bookmarklet.php
===================================================================
--- wp-admin/bookmarklet.php	(.../2.0.6)	(revision 5177)
+++ wp-admin/bookmarklet.php	(.../2.0.10)	(revision 5177)
@@ -37,7 +37,7 @@
 	
   
 $content  = wp_specialchars($_REQUEST['content']);
-$popupurl = attribute_escape(stripslashes($_REQUEST['popupurl']));
+$popupurl = clean_url(stripslashes($_REQUEST['popupurl']));
     if ( !empty($content) ) {
         $post->post_content = wp_specialchars( stripslashes($_REQUEST['content']) );
     } else {
Index: wp-admin/admin-db.php
===================================================================
--- wp-admin/admin-db.php	(.../2.0.6)	(revision 5177)
+++ wp-admin/admin-db.php	(.../2.0.10)	(revision 5177)
@@ -110,7 +110,7 @@
 
 	if (!$update) {
 		$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent')");
-		$cat_ID = $wpdb->insert_id;
+		$cat_ID = (int) $wpdb->insert_id;
 	} else {
 		$wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent' WHERE cat_ID = '$cat_ID'");
 	}
@@ -207,7 +207,7 @@
 	if (!$category_nicename = sanitize_title($cat_name))
 		return 0;
 
-	return $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'");
+	return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'");
 }
 
 function wp_delete_user($id, $reassign = 'novalue') {
@@ -270,6 +270,8 @@
 	if ( !empty($link_id) )
 		$update = true;
 
+	$link_id = (int) $link_id;
+
 	if( trim( $link_name ) == '' )
 		return 0;
 	$link_name = apply_filters('pre_link_name', $link_name);
@@ -326,7 +328,7 @@
 			WHERE link_id='$link_id'");
 	} else {
 		$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_category, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_category', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')");
-		$link_id = $wpdb->insert_id;
+		$link_id = (int) $wpdb->insert_id;
 	}
 	
 	if ( $update )
Index: wp-admin/options-permalink.php
===================================================================
--- wp-admin/options-permalink.php	(.../2.0.6)	(revision 5177)
+++ wp-admin/options-permalink.php	(.../2.0.10)	(revision 5177)
@@ -168,7 +168,7 @@
 <form action="options-permalink.php" method="post">
 <?php wp_nonce_field('update-permalink') ?>
    <p>
-<textarea rows="5" style="width: 98%;" name="rules"><?php echo $wp_rewrite->mod_rewrite_rules(); ?>
+<textarea rows="5" style="width: 98%;" name="rules"><?php echo wp_specialchars($wp_rewrite->mod_rewrite_rules()); ?>
 </textarea>
     </p>
 </form>
Index: wp-admin/import/livejournal.php
===================================================================
--- wp-admin/import/livejournal.php	(.../2.0.6)	(revision 5177)
+++ wp-admin/import/livejournal.php	(.../2.0.10)	(revision 5177)
@@ -80,7 +80,7 @@
 			$comments = $comments[1];
 			
 			if ( $comments ) {
-				$comment_post_ID = $post_id;
+				$comment_post_ID = (int) $post_id;
 				$num_comments = 0;
 				foreach ($comments as $comment) {
 					preg_match('|<event>(.*?)</event>|is', $comment, $comment_content);
Index: wp-admin/import/dotclear.php
===================================================================
--- wp-admin/import/dotclear.php	(.../2.0.6)	(revision 5177)
+++ wp-admin/import/dotclear.php	(.../2.0.10)	(revision 5177)
@@ -430,8 +430,8 @@
 				extract($comment);
 				
 				// WordPressify Data
-				$comment_ID = ltrim($comment_id, '0');
-				$comment_post_ID = $postarr[$post_id];
+				$comment_ID = (int) ltrim($comment_id, '0');
+				$comment_post_ID = (int) $postarr[$post_id];
 				$comment_approved = "$comment_pub";
 				$name = $wpdb->escape(csc ($comment_auteur));
 				$email = $wpdb->escape($comment_email);
Index: wp-admin/import/mt.php
===================================================================
--- wp-admin/import/mt.php	(.../2.0.6)	(revision 5177)
+++ wp-admin/import/mt.php	(.../2.0.10)	(revision 5177)
@@ -169,7 +169,7 @@
 			return;
 		}
 		$this->file = $file['file'];
-		$this->id = $file['id'];
+		$this->id = (int) $file['id'];
 
 		$this->get_entries();
 		$this->mt_authors_form();
@@ -293,7 +293,7 @@
 					}
 				}
 
-				$comment_post_ID = $post_id;
+				$comment_post_ID = (int) $post_id;
 				$comment_approved = 1;
 
 				// Now for comments

