Skip to content

ripgrep echos unescaped input to terminal, for filenames and regexes #2958

Open
@andychu

Description

@andychu

Please tick this box to confirm you have reviewed the above.

  • I have a different issue.

What version of ripgrep are you using?

13.0.0

How did you install ripgrep?

apt-get

What operating system are you using ripgrep on?

Debian

Describe your bug.

ripgrep echos unescaped input to terminal, for filenames and regexes

What are the steps to reproduce the behavior?

red=$'\x1b[31m RED \x1b[0;0m'

rg pat "$red" # filename

rg "$red' # pattern

What is the actual behavior?

I see red text

What is the expected behavior?

It should probably be escaped, at least in the filename case

I noticed this when testing a bunch of programs, as mentioned here

https://lobste.rs/s/qwcov5/deja_vu_ghostly_cves_my_terminal_title#c_js5pfq

There are two categories of programs:

  • bash, perl, python2, lua, node JS, grep, ripgrep

vs.

  • ls and cat (coreutils), python3, ruby, OSH/YSH

This is possibly debatable, but I think the latter behavior is better

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionAn issue that is lacking clarity on one or more points.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions