From a5394884627db6f6091c4b85b635af81c20f0f31 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20Engdeg=C3=A5rd?= Date: Fri, 21 Aug 2020 16:09:04 +0200 Subject: [PATCH] Always make a multibyte string for the frame title (bug#42904) * src/xdisp.c (gui_consider_frame_title): Multibyte-encode any raw bytes in the title, and then pass a multibyte string to the back-end for use as a frame title. This cuts down a little on the rubbish shown when raw bytes sneak in by mistake (as part of the buffer name, for instance). --- src/xdisp.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/xdisp.c b/src/xdisp.c index 34644dff39c..e2ebbbdce72 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -12565,6 +12565,11 @@ gui_consider_frame_title (Lisp_Object frame) display_mode_element (&it, 0, -1, -1, fmt, Qnil, false); len = MODE_LINE_NOPROP_LEN (title_start); title = mode_line_noprop_buf + title_start; + /* Make sure that any raw bytes in the title are properly + represented by their multibyte sequences. */ + ptrdiff_t nchars = 0; + len = str_as_multibyte (title, mode_line_noprop_buf_end - title, + len, &nchars); unbind_to (count, Qnil); /* Set the title only if it's changed. This avoids consing in @@ -12576,9 +12581,10 @@ gui_consider_frame_title (Lisp_Object frame) || SBYTES (f->name) != len || memcmp (title, SDATA (f->name), len) != 0) && FRAME_TERMINAL (f)->implicit_set_name_hook) - FRAME_TERMINAL (f)->implicit_set_name_hook (f, - make_string (title, len), - Qnil); + { + Lisp_Object title_string = make_multibyte_string (title, nchars, len); + FRAME_TERMINAL (f)->implicit_set_name_hook (f, title_string, Qnil); + } } } -- 2.39.2