Index: wp-includes/query.php
===================================================================
--- wp-includes/query.php	(revision 6217)
+++ wp-includes/query.php	(working copy)
@@ -749,8 +749,12 @@
 		$search = '';
 		$groupby = '';
 
-		if ( !isset($q['post_type']) )
-			$q['post_type'] = 'post';
+		if ( !isset($q['post_type']) ) {
+			if ( $this->is_search )
+				$q['post_type'] = 'any';
+			else
+				$q['post_type'] = 'post';
+		}
 		$post_type = $q['post_type'];
 		if ( !isset($q['posts_per_page']) || $q['posts_per_page'] == 0 )
 			$q['posts_per_page'] = get_option('posts_per_page');
@@ -883,8 +887,7 @@
 			$q['s'] = stripslashes($q['s']);
 			if ($q['sentence']) {
 				$q['search_terms'] = array($q['s']);
-			}
-			else {
+			} else {
 				preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $q[s], $matches);
 				$q['search_terms'] = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
 			}
@@ -892,10 +895,10 @@
 			$searchand = '';
 			foreach((array)$q['search_terms'] as $term) {
 				$term = addslashes_gpc($term);
-				$search .= "{$searchand}((post_title LIKE '{$n}{$term}{$n}') OR (post_content LIKE '{$n}{$term}{$n}'))";
+				$search .= "{$searchand}((post_title LIKE '{$n}{$term}{$n}') OR (post_content LIKE '{$n}{$term}{$n}')";
 				$searchand = ' AND ';
 			}
-			$term = addslashes_gpc($q['s']);
+			$term = $wpdb->escape($q['s']);
 			if (!$q['sentence'] && count($q['search_terms']) > 1 && $q['search_terms'][0] != $q['s'] )
 				$search .= " OR (post_title LIKE '{$n}{$term}{$n}') OR (post_content LIKE '{$n}{$term}{$n}')";
 
@@ -1145,6 +1148,8 @@
 			$where .= " AND post_type = 'page'";
 		} elseif ($this->is_single) {
 			$where .= " AND post_type = 'post'";
+		} elseif ( 'any' == $post_type ) {
+			$where .= '';
 		} else {
 			$where .= " AND post_type = '$post_type'";
 		}
