Author: futatuki
Date: Sun Oct  4 14:12:07 2020
New Revision: 1882234

URL: http://svn.apache.org/viewvc?rev=1882234&view=rev
Log:
Fix file name to edit from utf8 to local style.

* subversion/libsvn_subr/cmdline.c
  (svn_cmdline__edit_file_externally):
  Apply svn_path_cstring_from_utf8() to target file name after escape_shell().
  (svn_cmdline__edit_string_externally):
  Fix order to apply svn_path_cstring_from_utf8() and escape_shell().

Suggested by: stsp (applying order of file name conversion)
Reviewed by: stsp (svn_cmdline__edit_file_externally)

Modified:
    subversion/trunk/subversion/libsvn_subr/cmdline.c

Modified: subversion/trunk/subversion/libsvn_subr/cmdline.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/cmdline.c?rev=1882234&r1=1882233&r2=1882234&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/cmdline.c (original)
+++ subversion/trunk/subversion/libsvn_subr/cmdline.c Sun Oct  4 14:12:07 2020
@@ -1405,6 +1405,7 @@ svn_cmdline__edit_file_externally(const
                                   apr_pool_t *pool)
 {
   const char *editor, *cmd, *base_dir, *file_name, *base_dir_apr;
+  const char *file_name_local;
   char *old_cwd;
   int sys_err;
   apr_status_t apr_err;
@@ -1428,9 +1429,11 @@ svn_cmdline__edit_file_externally(const
     return svn_error_wrap_apr
       (apr_err, _("Can't change working directory to '%s'"), base_dir);
 
+  SVN_ERR(svn_path_cstring_from_utf8(&file_name_local,
+                                     escape_path(pool, file_name), pool));
   /* editor is explicitly documented as being interpreted by the user's shell,
      and as such should already be quoted/escaped as needed. */
-  cmd = apr_psprintf(pool, "%s %s", editor, escape_path(pool, file_name));
+  cmd = apr_psprintf(pool, "%s %s", editor, file_name_local);
   sys_err = system(cmd);
 
   apr_err = apr_filepath_set(old_cwd, pool);
@@ -1586,13 +1589,14 @@ svn_cmdline__edit_string_externally(svn_
     goto cleanup;
 
   /* Prepare the editor command line.  */
-  err = svn_utf_cstring_from_utf8(&tmpfile_native, tmpfile_name, pool);
+  err = svn_utf_cstring_from_utf8(&tmpfile_native,
+                                  escape_path(pool, tmpfile_name), pool);
   if (err)
     goto cleanup;
 
   /* editor is explicitly documented as being interpreted by the user's shell,
      and as such should already be quoted/escaped as needed. */
-  cmd = apr_psprintf(pool, "%s %s", editor, escape_path(pool, tmpfile_native));
+  cmd = apr_psprintf(pool, "%s %s", editor, tmpfile_native);
 
   /* If the caller wants us to leave the file around, return the path
      of the file we'll use, and make a note not to destroy it.  */


Reply via email to