Index: wp-includes/query.php
===================================================================
--- wp-includes/query.php	(revision 21625)
+++ wp-includes/query.php	(working copy)
@@ -2174,7 +2174,9 @@
 		}
 
 		// If a search pattern is specified, load the posts that match
-		if ( !empty($q['s']) ) {
+		// Sanity check: search string shouldn't be more than 1600 characters
+		// (some browsers won't send more than 2000 characters incl. the URL in a urlencoded GET request).
+		if ( !empty($q['s']) && strlen($q['s']) < 1600 ) {
 			// added slashes screw with quote grouping when done early, so done later
 			$q['s'] = stripslashes($q['s']);
 			if ( empty( $_GET['s'] ) && $this->is_main_query() )
@@ -2183,11 +2185,24 @@
 				$q['search_terms'] = array($q['s']);
 			} else {
 				preg_match_all('/".*?("|$)|((?<=[\r\n\t ",+])|^)[^\r\n\t ",+]+/', $q['s'], $matches);
-				$q['search_terms'] = array_map('_search_terms_tidy', $matches[0]);
+				$q['_search_terms'] = array_map('_search_terms_tidy', $matches[0]);
+				$q['search_terms'] = array();
+
+				foreach ( (array) $q['_search_terms'] as $term ) {
+					if ( empty($term) || strlen($term) < 3 )
+						continue;
+					$q['search_terms'][] = $term;
+				}
+
+				unset($q['_search_terms']);
+				// if the search string has only short terms or more than 10 terms match it as sentence
+				if ( empty($q['search_terms']) || count($q['search_terms']) > 10 )
+					$q['search_terms'] = array($q['s']);
 			}
+
 			$n = !empty($q['exact']) ? '' : '%';
 			$searchand = '';
-			foreach( (array) $q['search_terms'] as $term ) {
+			foreach( $q['search_terms'] as $term ) {
 				$term = esc_sql( like_escape( $term ) );
 				$search .= "{$searchand}(($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}'))";
 				$searchand = ' AND ';
