diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2022-07-10 10:13:27 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2022-07-10 10:13:27 -0400 |
commit | 46a2e5dc93ccbb36309f859460cb527c91adc4d1 (patch) | |
tree | e5f45008550050515dee2b1d46335eeecbbe4a94 /src/dired.c | |
parent | 118e05f570b127f9272c5dea1ae9a739531e238c (diff) | |
download | emacs-46a2e5dc93ccbb36309f859460cb527c91adc4d1.tar.gz emacs-46a2e5dc93ccbb36309f859460cb527c91adc4d1.tar.bz2 emacs-46a2e5dc93ccbb36309f859460cb527c91adc4d1.zip |
* src/dired.c (directory_files_internal): Fix bug#56469
Avoid concatenating encoded and decoded file names.
Diffstat (limited to 'src/dired.c')
-rw-r--r-- | src/dired.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/dired.c b/src/dired.c index 6bb8c2fcb9f..9aeff516369 100644 --- a/src/dired.c +++ b/src/dired.c @@ -219,6 +219,13 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full, } #endif + if (!NILP (full) && !STRING_MULTIBYTE (directory)) + { /* We will be concatenating 'directory' with local file name. + We always decode local file names, so in order to safely concatenate + them we need 'directory' to be decoded as well (bug#56469). */ + directory = DECODE_FILE (directory); + } + ptrdiff_t directory_nbytes = SBYTES (directory); re_match_object = Qt; @@ -263,9 +270,10 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full, ptrdiff_t name_nbytes = SBYTES (name); ptrdiff_t nbytes = directory_nbytes + needsep + name_nbytes; ptrdiff_t nchars = SCHARS (directory) + needsep + SCHARS (name); - finalname = make_uninit_multibyte_string (nchars, nbytes); - if (nchars == nbytes) - STRING_SET_UNIBYTE (finalname); + /* FIXME: Why not make them all multibyte? */ + finalname = (nchars == nbytes) + ? make_uninit_string (nbytes) + : make_uninit_multibyte_string (nchars, nbytes); memcpy (SDATA (finalname), SDATA (directory), directory_nbytes); if (needsep) SSET (finalname, directory_nbytes, DIRECTORY_SEP); |