Skip to content

Regression: FZF_CURRENT_ITEM breaks --preview when items contain NUL #4806

Description

@hguandl

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.73.0 (a24deef)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

In v0.73.0, every child process fzf spawns (eg,. preview) fails to start when the current item contains a NUL byte. v0.72.0 is unaffected.

The regression was introduced by #4803, which adds FZF_CURRENT_ITEM to the child environment by appending the raw item text:

fzf/src/terminal.go

Lines 1441 to 1443 in de1fca9

if item := t.currentItem(); item != nil {
env = append(env, "FZF_CURRENT_ITEM="+item.AsString(t.ansi))
}

Items may contain NUL bytes (e.g. when --delimiter='\x00' is used to encode multi-field records on a single line). Go's os/exec rejects any environment entry containing NUL and the spawn fails, as the following command shows:

$ printf '\0foo\0/\n' | fzf --delimiter=$'\0' --preview 'echo ok'
  • v0.72.0: preview window shows ok, fzf is usable.
  • v0.73.0: the preview pane reports exec: environment variable contains NUL.

A typical project affected is Aloxaf/fzf-tab, which is a widely-used Zsh completion plugin. It uses \n as record separator and \x00 as an inner field delimiter to encode colors per line, paired with --delimiter='\x00' --nth=2,3. This is its core data format and has worked across many previous fzf versions. After upgrading fzf to v0.73.0, all fzf-tab previews stop working and complain the os/exec error.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions