Correctly encode and decode filenames on NS

* src/nsfns.m (Fns_read_file_name): Run dir through ENCODE_FILE
and fname through DECODE_FILE.
This commit is contained in:
Po Lu 2022-05-04 15:31:32 +08:00
parent 273b0b95c2
commit 4c9a7010bc

View file

@ -1677,16 +1677,18 @@ Frames are listed from topmost (first) to bottommost (last). */)
BOOL isSave = NILP (mustmatch) && NILP (dir_only_p);
id panel;
Lisp_Object fname = Qnil;
NSString *promptS = NILP (prompt) || !STRINGP (prompt) ? nil :
[NSString stringWithLispString:prompt];
NSString *dirS = NILP (dir) || !STRINGP (dir) ?
[NSString stringWithLispString:BVAR (current_buffer, directory)] :
[NSString stringWithLispString:dir];
NSString *initS = NILP (init) || !STRINGP (init) ? nil :
[NSString stringWithLispString:init];
NSString *promptS, *dirS, *initS, *str;
NSEvent *nxev;
promptS = (NILP (prompt) || !STRINGP (prompt)
? nil : [NSString stringWithLispString: prompt]);
dirS = (NILP (dir) || !STRINGP (dir)
? [NSString stringWithLispString:
ENCODE_FILE (BVAR (current_buffer, directory))] :
[NSString stringWithLispString: ENCODE_FILE (dir)]);
initS = (NILP (init) || !STRINGP (init)
? nil : [NSString stringWithLispString: init]);
check_window_system (NULL);
if (fileDelegate == nil)
@ -1758,9 +1760,15 @@ Frames are listed from topmost (first) to bottommost (last). */)
if (ns_fd_data.ret == MODAL_OK_RESPONSE)
{
NSString *str = ns_filename_from_panel (panel);
if (! str) str = ns_directory_from_panel (panel);
if (str) fname = [str lispString];
str = ns_filename_from_panel (panel);
if (!str)
str = ns_directory_from_panel (panel);
if (str)
fname = [str lispString];
if (!NILP (fname))
fname = DECODE_FILE (fname);
}
[[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow];