Index: src/wp-includes/class-wp-embed.php
===================================================================
--- src/wp-includes/class-wp-embed.php	(revision 30793)
+++ src/wp-includes/class-wp-embed.php	(working copy)
@@ -326,7 +326,7 @@
 	 * @return string Potentially modified $content.
 	 */
 	public function autoembed( $content ) {
-		return preg_replace_callback( '|^\s*(https?://[^\s"]+)\s*$|im', array( $this, 'autoembed_callback' ), $content );
+		return preg_replace_callback( '|^(\s*)(https?://[^\s"]+)(\s*)$|im', array( $this, 'autoembed_callback' ), $content );
 	}
 
 	/**
@@ -340,10 +340,10 @@
 	public function autoembed_callback( $match ) {
 		$oldval = $this->linkifunknown;
 		$this->linkifunknown = false;
-		$return = $this->shortcode( array(), $match[1] );
+		$return = $this->shortcode( array(), $match[2] );
 		$this->linkifunknown = $oldval;
 
-		return "\n$return\n";
+		return $match[1] . $return . $match[3];
 	}
 
 	/**
