Index: wp-includes/shortcodes.php
===================================================================
--- wp-includes/shortcodes.php	(revision 7811)
+++ wp-includes/shortcodes.php	(working copy)
@@ -72,12 +72,16 @@
 	if (empty($shortcode_tags) || !is_array($shortcode_tags))
 		return $content;
 
+	$pattern = get_shortcode_regex();
+	return preg_replace_callback('/'.$pattern.'/s', 'do_shortcode_tag', $content);
+}
+
+function get_shortcode_regex() {
+	global $shortcode_tags;
 	$tagnames = array_keys($shortcode_tags);
 	$tagregexp = join( '|', array_map('preg_quote', $tagnames) );
 
-	$pattern = '/\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\1\])?/s';
-
-	return preg_replace_callback($pattern, 'do_shortcode_tag', $content);
+	return '\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\1\])?';
 }
 
 function do_shortcode_tag($m) {
Index: wp-includes/formatting.php
===================================================================
--- wp-includes/formatting.php	(revision 7811)
+++ wp-includes/formatting.php	(working copy)
@@ -92,6 +92,7 @@
 	if (strpos($pee, '<pre') !== false)
 		$pee = preg_replace_callback('!(<pre.*?>)(.*?)</pre>!is', 'clean_pre', $pee );
 	$pee = preg_replace( "|\n</p>$|", '</p>', $pee );
+	$pee = preg_replace('/<p>\s*?(' . get_shortcode_regex() . ')\s*<\/p>/s', '$1', $pee); // don't auto-p wrap shortcodes that stand alone
 
 	return $pee;
 }

