diff --git a/gdb/completer.c b/gdb/completer.c
index 8168f79de0e..44da6548eb4 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -181,13 +181,6 @@ static const char gdb_completer_file_name_break_characters[] =
    sequences as strings.  */
 static const char gdb_completer_quote_characters[] = "'";
 
-/* Accessor for some completer data that may interest other files.  */
-
-const char *
-get_gdb_completer_quote_characters (void)
-{
-  return gdb_completer_quote_characters;
-}
 
 /* This can be used for functions which don't want to complete on
    symbols but don't want to complete on anything else either.  */
@@ -1269,6 +1262,9 @@ complete_line_internal_1 (completion_tracker &tracker,
   set_rl_completer_word_break_characters
     (current_language->word_break_characters ());
 
+  /* Likewise for the quote characters.  */
+  rl_completer_quote_characters = gdb_completer_quote_characters;
+
   /* Decide whether to complete on a list of gdb commands or on
      symbols.  */
   tmp_command = (char *) alloca (point + 1);
diff --git a/gdb/completer.h b/gdb/completer.h
index f604a95011f..0a95ced8a80 100644
--- a/gdb/completer.h
+++ b/gdb/completer.h
@@ -619,8 +619,6 @@ extern void reggroup_completer (struct cmd_list_element *,
 				completion_tracker &tracker,
 				const char *, const char *);
 
-extern const char *get_gdb_completer_quote_characters (void);
-
 extern char *gdb_completion_word_break_characters (void);
 
 /* Set the word break characters array to BREAK_CHARS.  This function
diff --git a/gdb/testsuite/gdb.base/filename-completion.exp b/gdb/testsuite/gdb.base/filename-completion.exp
index 20ca227f96d..7d8ab1a3350 100644
--- a/gdb/testsuite/gdb.base/filename-completion.exp
+++ b/gdb/testsuite/gdb.base/filename-completion.exp
@@ -37,6 +37,9 @@ proc setup_directory_tree {} {
     remote_exec host "mkdir -p ${root}/cc1"
     remote_exec host "touch ${root}/cc2"
 
+    remote_exec host "touch \"${root}/aaa/aa bb\""
+    remote_exec host "touch \"${root}/aaa/aa cc\""
+
     return $root
 }
 
@@ -45,26 +48,49 @@ proc setup_directory_tree {} {
 # sub-directory of the user's home directory ROOT might have been
 # modified to replace the $HOME prefix with a single "~" character.
 proc run_tests { root } {
-    test_gdb_complete_none "file ${root}/xx" \
-	"expand a non-existent filename"
-
-    test_gdb_complete_unique "file ${root}/a" \
-	"file ${root}/aaa/" "" false \
-	"expand a unique filename"
-
-    test_gdb_complete_multiple "file ${root}/" \
-	"b" "b" {
-	    "bb1/"
-	    "bb2/"
-	} "" "" false \
-	"expand multiple directory names"
-
-    test_gdb_complete_multiple "file ${root}/" \
-	"c" "c" {
-	    "cc1/"
-	    "cc2"
-	} "" "" false \
-	"expand mixed directory and file names"
+
+    # Completing 'thread apply all ...' commands uses a custom word
+    # point.  At one point we had a bug where doing this would break
+    # completion of quoted filenames that contained white space.
+    test_gdb_complete_unique "thread apply all hel" \
+	"thread apply all help" " " false \
+	"complete a 'thread apply all' command"
+
+    foreach_with_prefix qc [list "" "'"] {
+	test_gdb_complete_none "file ${qc}${root}/xx" \
+	    "expand a non-existent filename"
+
+	test_gdb_complete_unique "file ${qc}${root}/a" \
+	    "file ${qc}${root}/aaa/" "" false \
+	    "expand a unique filename"
+
+	test_gdb_complete_multiple "file ${qc}${root}/" \
+	    "b" "b" {
+		"bb1/"
+		"bb2/"
+	    } "" "${qc}" false \
+	    "expand multiple directory names"
+
+	test_gdb_complete_multiple "file ${qc}${root}/" \
+	    "c" "c" {
+		"cc1/"
+		"cc2"
+	    } "" "${qc}" false \
+	    "expand mixed directory and file names"
+
+	# GDB does not currently escape word break characters
+	# (e.g. white space) correctly in unquoted filenames.
+	if { $qc ne "" } {
+	    set sp " "
+
+	    test_gdb_complete_multiple "file ${qc}${root}/aaa/" \
+		"a" "a${sp}" {
+		    "aa bb"
+		    "aa cc"
+		} "" "${qc}" false \
+		"expand filenames containing spaces"
+	}
+    }
 }
 
 gdb_start
diff --git a/gdb/top.c b/gdb/top.c
index cf7d3a913ba..8df684ec8b4 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -2142,7 +2142,6 @@ init_main (void)
   rl_completion_word_break_hook = gdb_completion_word_break_characters;
   rl_attempted_completion_function = gdb_rl_attempted_completion_function;
   set_rl_completer_word_break_characters (default_word_break_characters ());
-  rl_completer_quote_characters = get_gdb_completer_quote_characters ();
   rl_completion_display_matches_hook = cli_display_match_list;
   rl_readline_name = "gdb";
   rl_terminal_name = getenv ("TERM");
