Index: wp-includes/js/autosave.js
===================================================================
--- wp-includes/js/autosave.js	(revision 7159)
+++ wp-includes/js/autosave.js	(working copy)
@@ -92,6 +92,7 @@
 			{
 				action: 'sample-permalink',
 				post_id: post_id,
+				new_title: jQuery('#title').val(), 
 				samplepermalinknonce: jQuery('#samplepermalinknonce').val()
 			},
 			function(data) {
Index: wp-admin/admin-ajax.php
===================================================================
--- wp-admin/admin-ajax.php	(revision 7159)
+++ wp-admin/admin-ajax.php	(working copy)
@@ -571,7 +571,9 @@
 case 'sample-permalink':
 	check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' );
 	$post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0;
-	die(get_sample_permalink_html($post_id, $_POST['new_title'], $_POST['new_slug']));
+	$title = isset($_POST['new_title'])? $_POST['new_title'] : '';
+	$slug = isset($_POST['new_slug'])? $_POST['new_slug'] : '';
+	die(get_sample_permalink_html($post_id, $title, $slug));
 break;
 default :
 	do_action( 'wp_ajax_' . $_POST['action'] );
Index: wp-admin/includes/post.php
===================================================================
--- wp-admin/includes/post.php	(revision 7159)
+++ wp-admin/includes/post.php	(working copy)
@@ -581,7 +581,7 @@
 	}
 }
 
-function get_sample_permalink($id, $title, $name = null) {
+function get_sample_permalink($id, $title=null, $name = null) {
 	$post = &get_post($id);
 	if (!$post->ID) {
 		return array('', '');
@@ -589,17 +589,19 @@
 	$original_status = $post->post_status;
 	$original_date = $post->post_date;
 	$original_name = $post->post_name;
-	$original_title = $post->post_title;
 
-	$post->post_title = $title;
-	$post->post_name = sanitize_title($post->post_name? $post->post_name : $post->post_title, $post->ID);
-
+	// Hack: get_permalink would return ugly permalink for
+	// drafts, so we will fake, that our post is published
 	if (in_array($post->post_status, array('draft', 'pending'))) {
 		$post->post_status = 'publish';
 		$post->post_date = date('Y-m-d H:i:s');
+		$post->post_name = sanitize_title($post->post_name? $post->post_name : $post->post_title, $post->ID); 
 	}
+
+	// If the user wants to set a new name -- override the current one
+	// Note: if empty name is supplied -- use the title instead, see #6072
 	if (!is_null($name)) {
-		$post->post_name = sanitize_title($name? $name : $post->post_title, $post->ID);
+		$post->post_name = sanitize_title($name? $name : $title, $post->ID);
 	}
 
 	$permalink = get_permalink($post, true);
