Shougo / ddu-ui-ff

Fuzzy finder UI for ddu.vim
MIT License
55 stars 26 forks source link

If the preview buffer name contains `|`, the string following `|` is treated as a command. #81

Closed tennashi closed 1 year ago

tennashi commented 1 year ago

Warning: I will close the issue without the minimal init.vim and the reproduction instructions.

Problems summary

Previewing an item with item.word containing | will execute the string following |.

Probably need to escape here.

https://github.com/Shougo/ddu-ui-ff/blob/36a0c44165ef081740b8721c7a8a4fe3b2a93e90/denops/%40ddu-ui-ff/preview.ts#L272-L291

Expected

| is treated as just a string.

Environment Information

Provide a minimal init.vim/vimrc without plugin managers (Required!)

" Your minimal init.vim/vimrc
set runtimepath+=~/path/to/ddu.vim/
set runtimepath+=~/path/to/ddu-ui-ff/
set runtimepath+=~/path/to/test/

call ddu#custom#patch_global({
\ 'uiParams': {
\   'ff': {
\     'autoAction': {'name': 'preview'},
\   },
\ },
\})

type Params = Record<never, never>;

export class Source extends BaseSource { kind = "test";

gather(_args: GatherArguments): ReadableStream<Item[]> { return new ReadableStream({ start(controler) { controler.enqueue([ { word: "| !ls" }, ]); controler.close(); }, }); }

params(): Params { return {}; } }


* `~/path/to/test_kind/denops/@ddu-kinds/test.ts`
```ts
import {
  ActionArguments,
  ActionFlags,
  BaseKind,
  Previewer,
} from "https://deno.land/x/ddu_vim@v2.4.0/types.ts";
import { GetPreviewerArguments } from "https://deno.land/x/ddu_vim@v2.4.0/base/kind.ts";

type Params = Record<never, never>;

export class Kind extends BaseKind<Params> {
  actions: Record<
    string,
    (args: ActionArguments<Params>) => Promise<ActionFlags>
  > = {};

  getPreviewer(_args: GetPreviewerArguments): Promise<Previewer | undefined> {
    return Promise.resolve({
      kind: "nofile",
      contents: ["hoge"],
    });
  }

  params(): Params {
    return {};
  }
}

How to reproduce the problem from neovim/Vim startup (Required!)

  1. :call ddu#start({'ui': 'ff', 'sources': [{'name': 'test'}]})

Screenshot (if possible)

Upload the log messages by :redir and :message (if errored)

Shougo commented 1 year ago

Fixed.