Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

syntastic#util#findFileInParent fails if directory contains a comma #2109

Closed
TBBle opened this issue Nov 14, 2017 · 1 comment
Closed

syntastic#util#findFileInParent fails if directory contains a comma #2109

TBBle opened this issue Nov 14, 2017 · 1 comment

Comments

@TBBle
Copy link
Contributor

TBBle commented Nov 14, 2017

The following code fails to escape directories with a comma in their name:

" Start in directory a:where and walk up the parent folders until it finds a
" file named a:what; return path to that file
function! syntastic#util#findFileInParent(what, where) abort " {{{2
    let old_suffixesadd = &suffixesadd
    let &suffixesadd = ''
    let file = findfile(a:what, escape(a:where, ' ') . ';')
    let &suffixesadd = old_suffixesadd
    return file
endfunction " }}}2

This manifests with the following test, assuming sphinx-build is present and selected as the checker:

touch conf.py
mkdir "a,b"
cd "a,b"
touch index.rst
vim index.rst

Since conf.py is invalid, correct behaviour is an error:
syntastic: error: checker rst/sphinx returned abnormal status 1

Invalid behaviour is no error. With g:syntastic_debug = 32 the following will be logged in the failure case:

syntastic: 2.559280: rst/sphinx: syntastic_rst_sphinx_source_dir = ''
syntastic: 2.559755: rst/sphinx: conf.py file not found

The fix is to add a comma to the characters to be escaped:

" Start in directory a:where and walk up the parent folders until it finds a
" file named a:what; return path to that file
function! syntastic#util#findFileInParent(what, where) abort " {{{2
    let old_suffixesadd = &suffixesadd
    let &suffixesadd = ''
    let file = findfile(a:what, escape(a:where, ' ,') . ';')
    let &suffixesadd = old_suffixesadd
    return file
endfunction " }}}2

Vim version as supplied with CentOS 7

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jun 10 2014 06:55:55)
Included patches: 1-160

Syntastic version installed with Vundle:

Syntastic version: 3.8.0-94 (Vim 704, Linux)
@lcd047
Copy link
Collaborator

lcd047 commented Nov 15, 2017

Sadly the problem is not limited to comma, the sequence *( f.i. breaks findfile(), and no combination of escaping can fix that. Then again this is Vim, where all problems are solved to 95%. Handling filenames is broken beyond repair. Looking at the sources I never cease to be surprised that there aren't more bug reports about just about everything involving filenames. shrug

Slm0n87 pushed a commit to Slm0n87/syntastic that referenced this issue Mar 7, 2019
findfile() appears to have some undocumented behaviour regarding
commands in the path string. So escape them when we escape spaces.

Closes vim-syntastic#2109
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants