Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

escape pyscript_path #57

Closed
josephholsten opened this issue Jan 29, 2016 · 3 comments · Fixed by #119
Closed

escape pyscript_path #57

josephholsten opened this issue Jan 29, 2016 · 3 comments · Fixed by #119

Comments

@josephholsten
Copy link

After upgrading, I now see an error:

E172: Only one file name allowed: pyfile /Users/josephholsten/Dropbox (Personal)/Mackup/.config/nvim/plugged/editorconfig-vim/plugin/editorconfig.py

I'm guessing this error is because the absolute path to my vim plugins includes whitespace.

I'm thinking we should either escape where pyscript_path is set plugin/editorconfig.vim:39 or where it's passed to pyscript plugin/editorconfig.vim:250.

@xuhdev
Copy link
Member

xuhdev commented Jan 30, 2016

@grafi-tt Would you mind fixing the problem please? Thanks!

@grafi-tt
Copy link
Contributor

grafi-tt commented Feb 1, 2016

As suggested by @josephholsten, escaping is required.
I found that places need to be correctly escaped is not only the line 250.
I escaped several places, and now it works fine with the builtin python and an external python command. If you appreciate pull request instead of a patch, I can make that.
Thanks!

diff --git a/plugin/editorconfig.vim b/plugin/editorconfig.vim
index 87fbaa6..9abd008 100644
--- a/plugin/editorconfig.vim
+++ b/plugin/editorconfig.vim
@@ -121,15 +121,15 @@ function! s:FindPythonFiles() " {{{1

     let l:python_core_files_dir = fnamemodify(
                 \ findfile(g:EditorConfig_python_files_dir . '/main.py',
-                \ ','.&runtimepath), ':p:h')
+                \ fnameescape(','.&runtimepath)), ':p:h')

     if empty(l:python_core_files_dir)
         let l:python_core_files_dir = ''
     else

-    " expand python core file path to full path, and remove the appending '/'
-    let l:python_core_files_dir = substitute(
-                \ fnamemodify(l:python_core_files_dir, ':p'), '/$', '', '')
+        " expand python core file path to full path, and remove the appending '/'
+        let l:python_core_files_dir = substitute(
+                    \ fnamemodify(l:python_core_files_dir, ':p'), '/$', '', '')
     endif

     let &shellslash = l:old_shellslash
@@ -247,7 +247,7 @@ function! s:InitializePythonBuiltin(editorconfig_core_py_dir) " {{{2
     " The following line modifies l:ret. This is a bit confusing but
     " unfortunately to be compatible with Vim 7.3, we cannot use pyeval. This
     " should be changed in the future.
-    execute s:pyfile_cmd s:pyscript_path
+    execute s:pyfile_cmd fnameescape(s:pyscript_path)

     return l:ret
 endfunction
@@ -391,8 +391,8 @@ endfunction
 function! s:UseConfigFiles_Python_External() " {{{2
 " Use external python interp to run the python EditorConfig Core

-    let l:cmd = s:editorconfig_python_interp . ' ' .
-                \ s:editorconfig_core_py_dir . '/main.py'
+    let l:cmd = shellescape(s:editorconfig_python_interp) . ' ' .
+                \ shellescape(s:editorconfig_core_py_dir . '/main.py')

     call s:SpawnExternalParser(l:cmd)

@xuhdev
Copy link
Member

xuhdev commented Feb 1, 2016

@grafi-tt I've applied the patch, thanks! 75fe572

@josephholsten Can you try it with the latest version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants