Index: shell/ev-window-title.c
===================================================================
--- shell/ev-window-title.c	(revision 2985)
+++ shell/ev-window-title.c	(working copy)
@@ -18,6 +18,7 @@
  */
 
 #include <config.h>
+#include <string.h>
 #include "ev-window-title.h"
 #include "ev-backends-manager.h"
 
@@ -88,13 +89,9 @@ ev_window_title_sanitize_extension (EvWi
 		if (g_ascii_strcasecmp (bad_extensions[i].backend, backend) == 0 && 
 		    g_str_has_suffix (*title, bad_extensions[i].ext)) {
 			char *new_title;
-			char *filename = get_filename_from_uri (window_title->uri);
-
-			new_title = g_strdup_printf ("%s (%s)", *title, filename);
+			new_title = g_strndup (*title, strlen(*title) - strlen(bad_extensions[i].ext));
 			g_free (*title);
 			*title = new_title;
-
-			g_free (filename);
 		}
 	}
 }
@@ -103,7 +100,7 @@ static void
 ev_window_title_update (EvWindowTitle *window_title)
 {
 	GtkWindow *window = GTK_WINDOW (window_title->window);
-	char *title = NULL, *password_title, *p;
+	char *document_title = NULL, *title = NULL, *password_title, *p;
 	EvPageCache *page_cache;
 
 	if (window_title->document != NULL) {
@@ -119,13 +116,15 @@ ev_window_title_update (EvWindowTitle *w
 
 			if (doc_title[0] != '\0' &&
 			    g_utf8_validate (doc_title, -1, NULL)) {
-				title = g_strdup (doc_title);
+				document_title = g_strdup (doc_title);
 			}
 		}
 	}
 
-	if (title && window_title->uri) {
-		ev_window_title_sanitize_extension (window_title, &title);
+	if (document_title && window_title->uri) {
+		ev_window_title_sanitize_extension (window_title, &document_title);
+		title = g_strdup_printf("%s (%s)", document_title, get_filename_from_uri (window_title->uri));
+		g_free(document_title);
 	} else if (window_title->uri) {
 		title = get_filename_from_uri (window_title->uri);
 	} else if (!title) {
