diff options
author | Eli Zaretskii <eliz@gnu.org> | 2018-05-18 16:34:19 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2018-05-18 16:34:19 +0300 |
commit | 3aab8626ba5080bb04d0fdae52d99c850a842a52 (patch) | |
tree | 938f2a9a24bde22329770c08e7019c2294a88f2b /lisp/startup.el | |
parent | 60ff8101449eea3a5ca4961299501efd83d011bd (diff) | |
download | emacs-3aab8626ba5080bb04d0fdae52d99c850a842a52.tar.gz |
Fix decoding of directories when "~" includes non-ASCII chars
* src/fileio.c (Fexpand_file_name): Don't build multibyte strings
from unibyte non-ASCII strings when NAME and DEFAULT_DIRECTORY
have different multibyteness, as this adds bytes to the byte
sequence, and in some situations, e.g., when the home directory
includes non-ASCII characters, can fail file APIs. (Bug#30755)
* lisp/startup.el (normal-top-level): Make sure default-directory
is set to a multibyte string when decoded on MS-Windows.
Diffstat (limited to 'lisp/startup.el')
-rw-r--r-- | lisp/startup.el | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lisp/startup.el b/lisp/startup.el index 5b2d3e58cba..83fd190ea2b 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -560,9 +560,17 @@ It is the default value of the variable `top-level'." (if default-directory (setq default-directory (if (eq system-type 'windows-nt) - ;; Convert backslashes to forward slashes. - (expand-file-name - (decode-coding-string default-directory coding t)) + ;; We pass the decoded default-directory as + ;; the 2nd arg to expand-file-name to make + ;; sure it sees a multibyte string as the + ;; default directory; this avoids the side + ;; effect of returning a unibyte string from + ;; expand-file-name because it still sees + ;; the undecoded value of default-directory. + (let ((defdir (decode-coding-string default-directory + coding t))) + ;; Convert backslashes to forward slashes. + (expand-file-name defdir defdir)) (decode-coding-string default-directory coding t)))))) ;; Decode all the important variables and directory lists, now |