summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2014-02-01 11:22:51 +0200
committerEli Zaretskii <eliz@gnu.org>2014-02-01 11:22:51 +0200
commitcb13e9a8427eb0f198f6c95f2107a41c264f93a2 (patch)
tree624e33482ab36cc2e8b149d5086681b3e411dfc0
parent94304aea88c1b80eb95ffaa8ffb88cf52207ec5b (diff)
downloademacs-cb13e9a8427eb0f198f6c95f2107a41c264f93a2.tar.gz
Fix bug #16558 with w32-shell-execute on remote file names.
src/w32fns.c (Fw32_shell_execute): Don't call file-exists-p for DOCUMENT that is a "remote" file name, i.e. a file-handler exists for it.
-rw-r--r--src/ChangeLog6
-rw-r--r--src/w32fns.c23
2 files changed, 25 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index ec17d7ace4f..8a8956bec31 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2014-02-01 Eli Zaretskii <eliz@gnu.org>
+
+ * w32fns.c (Fw32_shell_execute): Don't call file-exists-p for
+ DOCUMENT that is a "remote" file name, i.e. a file-handler exists
+ for it. (Bug#16558)
+
2014-01-30 Andreas Schwab <schwab@linux-m68k.org>
* process.c (create_process): Reset SIGPROF handler in the child.
diff --git a/src/w32fns.c b/src/w32fns.c
index 98456cd20d4..397b1796215 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -6892,7 +6892,8 @@ 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;
+ Lisp_Object absdoc, handler;
+ struct gcpro gcpro1;
#endif
CHECK_STRING (document);
@@ -6927,10 +6928,24 @@ an integer representing a ShowWindow flag:
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. */
+ GCPRO1 (absdoc);
absdoc = Fexpand_file_name (document, Qnil);
- if (!NILP (Ffile_exists_p (absdoc)))
- document = absdoc;
- document = ENCODE_FILE (document);
+ /* Don't call file handlers for file-exists-p, since they might
+ attempt to access the file, which could fail or produce undesired
+ consequences, see bug#16558 for an example. */
+ handler = Ffind_file_name_handler (absdoc, Qfile_exists_p);
+ if (NILP (handler))
+ {
+ Lisp_Object absdoc_encoded = ENCODE_FILE (absdoc);
+
+ if (faccessat (AT_FDCWD, SSDATA (absdoc_encoded), F_OK, AT_EACCESS) == 0)
+ document = absdoc_encoded;
+ else
+ document = ENCODE_FILE (document);
+ }
+ else
+ document = ENCODE_FILE (document);
+ UNGCPRO;
if (use_unicode)
{
wchar_t document_w[MAX_PATH], current_dir_w[MAX_PATH];