From: Eli Zaretskii Date: Wed, 25 Dec 2013 17:30:24 +0000 (+0200) Subject: Fix bug #16252 with 'mailto:' documents passed to w32-shell-execute. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~195 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9ab3ce4d2f1c6409d36072192bfce797ec189837;p=emacs.git Fix bug #16252 with 'mailto:' documents passed to w32-shell-execute. src/w32fns.c (Fw32_shell_execute): Make DOCUMENT absolute only if it is a file name. --- diff --git a/src/ChangeLog b/src/ChangeLog index a883182754d..1e8684c4ddb 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2013-12-25 Eli Zaretskii + + * w32fns.c (Fw32_shell_execute): Make DOCUMENT absolute only if it + is a file name. (Bug#16252) + 2013-12-25 Chong Yidong * keyboard.c (Voverriding_terminal_local_map): diff --git a/src/w32fns.c b/src/w32fns.c index c1621acf513..02850d8954d 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -6851,7 +6851,8 @@ operations: DOCUMENT is typically the name of a document file or a URL, but can also be a program executable to run, or a directory to open in the -Windows Explorer. +Windows Explorer. If it is a file, it must be a local one; this +function does not support remote file names. If DOCUMENT is a program executable, the optional third arg PARAMETERS can be a string containing command line parameters that will be passed @@ -6875,6 +6876,7 @@ an integer representing a ShowWindow flag: #ifndef CYGWIN int use_unicode = w32_unicode_filenames; char *doc_a = NULL, *params_a = NULL, *ops_a = NULL; + Lisp_Object absdoc; #endif CHECK_STRING (document); @@ -6903,7 +6905,16 @@ an integer representing a ShowWindow flag: ? XINT (show_flag) : SW_SHOWDEFAULT)); #else /* !CYGWIN */ current_dir = ENCODE_FILE (current_dir); - document = ENCODE_FILE (Fexpand_file_name (document, Qnil)); + /* We have a situation here. If DOCUMENT is a relative file name, + and is not in CURRENT_DIR, ShellExecute below will fail to find + it. So we need to make the file name absolute. But DOCUMENT + does not have to be a file, it can be a URL, for example. So we + make it absolute only if it is an existing file; if it is a file + that does not exist, tough. */ + absdoc = Fexpand_file_name (document, Qnil); + if (!NILP (Ffile_exists_p (absdoc))) + document = absdoc; + document = ENCODE_FILE (document); if (use_unicode) { wchar_t document_w[MAX_PATH], current_dir_w[MAX_PATH];