Subject: Re: 25.1; Curly quotes generate invalid strings, leading to a segfault

From: Paul Eggert <[email-masked]>
Date: Sun, 14 Aug 2016 09:51:43 -0500

On 08/14/2016 09:27 AM, Eli Zaretskii wrote:
> The "length = 1" part is only correct if the argument string is
> multibyte, and should otherwise count the number of bytes in
> uLSQM/uRSQ, right?

This string is by definition multibyte at that point, since that part of 
the code is inserting a Unicode character that is not ASCII.

More generally, Fsubstitute_command_keys is quite confused about unibyte 
versus multibyte issues. It merges together a number of strings, and 
assumes that they are all multibyte iff the original string is 
multibyte, which is obviously not true in general. (This problem is not 
limited to the requoting part of the code.) In master, I've altered the 
implementation to always generate either the original string, or an 
ASCII string, or a multibyte string. Since substitute-command-keys is 
not intended to be used on encoded unibyte text, that's good enough.