Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ› ripgrep JSON output causes panic with UTF character #1679

Open
mmottl opened this issue Apr 28, 2024 · 0 comments
Open

πŸ› ripgrep JSON output causes panic with UTF character #1679

mmottl opened this issue Apr 28, 2024 · 0 comments

Comments

@mmottl
Copy link

mmottl commented Apr 28, 2024

Consider the following text file containing a UTF character followed by newline:

❯ cat foo.txt
━

Here is the hex dump for clarity:

❯ xxd -p foo.txt
e294810a

Delta will interpret regular rg output just fine:

❯ rg "" foo.txt | delta
━

But it will panic when using JSON output:

❯ rg --json "" foo.txt | RUST_BACKTRACE=1 delta
thread 'main' panicked at src/handlers/grep.rs:389:50:
byte index 1 is not a char boundary; it is inside '━' (bytes 0..3) of `━`
stack backtrace:
β€’ foo.txt
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::str::slice_error_fail_rt
   3: core::str::slice_error_fail
   4: delta::handlers::grep::make_style_sections
   5: delta::handlers::grep::<impl delta::delta::StateMachine>::handle_grep_line
   6: delta::delta::delta
   7: delta::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant