Index: wp-includes/media.php
===================================================================
--- wp-includes/media.php	(revision 17444)
+++ wp-includes/media.php	(working copy)
@@ -169,6 +169,8 @@
 		// we have the actual image size, but might need to further constrain it if content_width is narrower
 		list( $width, $height ) = image_constrain_size_for_editor( $width, $height, $size );
 
+		$img_url = dirname($img_url) . '/' . urlencode(basename($img_url));
+
 		return array( $img_url, $width, $height, $is_intermediate );
 	}
 	return false;
@@ -565,7 +567,7 @@
 	$data = $imagedata['sizes'][$size];
 	// include the full filesystem path of the intermediate file
 	if ( empty($data['path']) && !empty($data['file']) ) {
-		$file_url = wp_get_attachment_url($post_id);
+		$file_url = wp_get_attachment_url($post_id); // What's this here for? and why is the return of this block of code completely different to the 2 above documented returns?
 		$data['path'] = path_join( dirname($imagedata['file']), $data['file'] );
 		$data['url'] = path_join( dirname($file_url), $data['file'] );
 	}
Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php	(revision 17444)
+++ wp-includes/post.php	(working copy)
@@ -3832,6 +3832,9 @@
 
 	$url = apply_filters( 'wp_get_attachment_url', $url, $post->ID );
 
+	if ( $url )
+		$url = dirname($url) . '/' . urlencode(basename($url)); // encode the filename
+
 	if ( 'attachment' != $post->post_type || empty( $url ) )
 		return false;
 
