Index: src/wp-admin/includes/ajax-actions.php
===================================================================
--- src/wp-admin/includes/ajax-actions.php	(revision 37021)
+++ src/wp-admin/includes/ajax-actions.php	(working copy)
@@ -2578,7 +2578,7 @@
 	$rel = '';
 	$url = empty( $attachment['url'] ) ? '' : $attachment['url'];
 	if ( strpos( $url, 'attachment_id') || get_attachment_link( $id ) == $url ) {
-		$rel = 'attachment wp-att-' . $id;
+		$rel = ' rel="attachment wp-att-' . $id . '"'; // Hard-coded string, $id is already sanitized
 	}
 
 	remove_filter( 'media_send_to_editor', 'image_media_send_to_editor' );
@@ -2595,13 +2595,13 @@
 		}
 
 		$title = ''; // We no longer insert title tags into <img> tags, as they are redundant.
-		$html = get_image_send_to_editor( $id, $caption, $title, $align, $url, $rel, $size, $alt );
+		$html = get_image_send_to_editor( $id, $caption, $title, $align, $url, (bool) $rel, $size, $alt );
 	} elseif ( wp_attachment_is( 'video', $post ) || wp_attachment_is( 'audio', $post )  ) {
 		$html = stripslashes_deep( $_POST['html'] );
 	} else {
 		$html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
 		if ( ! empty( $url ) ) {
-			$html = '<a href="' . esc_url( $url ) . '"' . 'rel="' . esc_attr( $rel ) . '">' . $html . '</a>';
+			$html = '<a href="' . esc_url( $url ) . '"' . $rel . '">' . $html . '</a>';
 		}
 	}
 
Index: src/wp-admin/includes/media.php
===================================================================
--- src/wp-admin/includes/media.php	(revision 37021)
+++ src/wp-admin/includes/media.php	(working copy)
@@ -111,24 +111,20 @@
  * @param string       $title   Image title attribute.
  * @param string       $align   Image CSS alignment property.
  * @param string       $url     Optional. Image src URL. Default empty.
- * @param string       $rel     Optional. Image rel attribute. Default empty.
+ * @param bool         $rel     Optional. Whether to add rel attribute. Default false.
  * @param string|array $size    Optional. Image size. Accepts any valid image size, or an array of width
  *                              and height values in pixels (in that order). Default 'medium'.
  * @param string       $alt     Optional. Image alt attribute. Default empty.
  * @return string The HTML output to insert into the editor.
  */
-function get_image_send_to_editor( $id, $caption, $title, $align, $url = '', $rel = '', $size = 'medium', $alt = '' ) {
+function get_image_send_to_editor( $id, $caption, $title, $align, $url = '', $rel = false, $size = 'medium', $alt = '' ) {
 
-	$html = get_image_tag($id, $alt, '', $align, $size);
+	$html = get_image_tag( $id, $alt, '', $align, $size );
 
-	if ( ! $rel ) {
-		$rel = ' rel="attachment wp-att-' . esc_attr( $id ) . '"';
-	} else {
-		$rel = ' rel="' . esc_attr( $rel ) . '"';
-	}
+	$rel = $rel ? ' rel="attachment wp-att-' . intval( $id ) . '"' : ''; 
 
 	if ( $url )
-		$html = '<a href="' . esc_attr($url) . "\"$rel>$html</a>";
+		$html = '<a href="' . esc_attr( $url ) . '"' . $rel . '>' . $html . '</a>';
 
 	/**
 	 * Filter the image HTML markup to send to the editor.
Index: tests/phpunit/tests/media.php
===================================================================
--- tests/phpunit/tests/media.php	(revision 37021)
+++ tests/phpunit/tests/media.php	(working copy)
@@ -1481,4 +1481,71 @@
 
 		$this->assertSame( $expected, $actual );
 	}
+
+	/**
+	 * @ticket 36084
+	 */
+	function test_get_image_send_to_editor_defaults() {
+		$id      = self::$large_id;
+		$caption = '';
+		$title   = 'A test title value.';
+		$align   = 'left';
+
+		// Calculate attachment data (default is medium).
+		$attachment = wp_get_attachment_image_src( $id, 'medium' );
+
+		$html = '<img src="%1$s" alt="" width="%2$d" height="%3$d" class="align%4$s size-medium wp-image-%5$d" />';
+		$expected = sprintf( $html, $attachment[0], $attachment[1], $attachment[2], $align, $id );
+
+		$this->assertSame( $expected, get_image_send_to_editor( $id, $caption, $title, $align ) );
+
+		$this->assertSame( $expected, get_image_send_to_editor( $id, $caption, $title, $align ) );
+	}
+
+	/**
+	 * @ticket 36084
+	 */
+	function test_get_image_send_to_editor_defaults_with_optional_params() {
+		$id      = self::$large_id;
+		$caption = 'A test caption.';
+		$title   = 'A test title value.';
+		$align   = 'left';
+		$url     = get_permalink( $id );
+		$rel     = true;
+		$size    = 'thumbnail';
+		$alt     = 'An example alt value.';
+
+		// Calculate attachment data.
+		$attachment = wp_get_attachment_image_src( $id, $size );
+
+		$html = '<a href="%1$s" rel="%2$s"><img src="%3$s" alt="%4$s" width="%5$d" height="%6$d" class="size-%8$s wp-image-%9$d" /></a>';
+		$html = '[caption id="attachment_%9$d" align="align%7$s" width="%5$d"]' . $html . ' %10$s[/caption]';
+
+		$expected = sprintf( $html, $url, 'attachment wp-att-' . $id, $attachment[0], $alt, $attachment[1], $attachment[2], $align, $size, $id, $caption );
+
+		$this->assertSame( $expected, get_image_send_to_editor( $id, $caption, $title, $align, $url, $rel, $size, $alt ) );
+	}
+
+	/**
+	 * @ticket 36084
+	 */
+	function test_get_image_send_to_editor_defaults_no_caption_no_rel() {
+		$id      = self::$large_id;
+		$caption = '';
+		$title   = 'A test title value.';
+		$align   = 'left';
+		$url     = get_permalink( $id );
+		$rel     = '';
+		$size    = 'thumbnail';
+		$alt     = 'An example alt value.';
+
+		// Calculate attachment data.
+		$attachment = wp_get_attachment_image_src( $id, $size );
+
+		$html = '<a href="%1$s"><img src="%2$s" alt="%3$s" width="%4$d" height="%5$d" class="align%6$s size-%7$s wp-image-%8$d" /></a>';
+
+		$expected = sprintf( $html, $url, $attachment[0], $alt, $attachment[1], $attachment[2], $align, $size, $id );
+
+		$this->assertSame( $expected, get_image_send_to_editor( $id, $caption, $title, $align, $url, $rel, $size, $alt ) );
+	}
 }
