junegunn / junegunn/fzf.vim

`preview.rb` parses path incorrectly if it contains special characters (e.g. `+`)

Open
#611 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Vim Script
Stars
10.3k
Forks
608
Avg merge
5d 8h
Merged PRs (30d)
2

Description

- Category
- [ ] Question
- [x] Bug
- [ ] Suggestion
- OS
- [x] Linux
- [ ] macOS
- [ ] Windows
- [ ] Etc.
- Vim
- [x] Vim
- [x] Neovim

Calling `:call fzf#vim#ag("", fzf#vim#with_preview('up:60%'))` and trying to preview a file with a `+` in the path will display nothing in the preview window.
The problem is the `COMMAND.gsub` in `preview.rb` line 20: it escapes `my/path+b/file.txt` to `my/path\+b/file.txt`, which gets picked up by `gsub` as a capture group and gets removed, so that the path looks like this:
`my/pathb/file.txt`.

=> This file can't be read, nothing is displayed.

Quick fixing hack was to change the escaping to something like `COMMAND.gsub('{}', Shellwords.shellescape(Shellwords.shellescape(path)).gsub('\\\\', '\\'))`, obviously this could be improved in some form.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.