Index: wp-includes/media.php
===================================================================
--- wp-includes/media.php	(revision 23435)
+++ wp-includes/media.php	(working copy)
@@ -693,6 +693,9 @@
 			unset( $attr['orderby'] );
 	}
 
+	if ( ! isset( $attr['link'] ) )
+		$attr['link'] = 'post';
+
 	extract(shortcode_atts(array(
 		'order'      => 'ASC',
 		'orderby'    => 'menu_order ID',
@@ -703,7 +706,8 @@
 		'columns'    => 3,
 		'size'       => 'thumbnail',
 		'include'    => '',
-		'exclude'    => ''
+		'exclude'    => '',
+		'splitter'   => '<br style="clear: both;" />'
 	), $attr));
 
 	$id = intval($id);
@@ -772,12 +776,12 @@
 		</style>
 		<!-- see gallery_shortcode() in wp-includes/media.php -->";
 	$size_class = sanitize_html_class( $size );
-	$gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
+	$gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class} gallery-link-{$attr['link']}'>";
 	$output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div );
 
 	$i = 0;
 	foreach ( $attachments as $id => $attachment ) {
-		$link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
+		$link = 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
 
 		$output .= "<{$itemtag} class='gallery-item'>";
 		$output .= "
@@ -792,11 +796,11 @@
 		}
 		$output .= "</{$itemtag}>";
 		if ( $columns > 0 && ++$i % $columns == 0 )
-			$output .= '<br style="clear: both" />';
+			$output .= $splitter;
 	}
 
 	$output .= "
-			<br style='clear: both;' />
+			" . $splitter . "
 		</div>\n";
 
 	return $output;
