All contributions

BurntSushi/ripgrep

ripgrep

A command line tool that recursively searches directories for a regex pattern while respecting your .gitignore. Written in Rust.

Language
Rust
GitHub stars
70,186
Merged changes
1

What we changed

Paths that contain bytes outside valid UTF-8 on Unix are now percent-encoded in terminal hyperlinks, so the file:// address is a valid URI and no raw bytes end up inside the OSC 8 sequence. Valid non-ASCII characters stay as they were, and nothing changes on Windows.

What this work shows

  • OSC 8 terminal hyperlinks
  • Percent-encoding file:// URLs
  • Invalid UTF-8 bytes and utf8_chunks in Rust
  • Rust unit tests
What was broken

Raw bytes inside a hyperlink

On Unix a filename can contain bytes that are not valid UTF-8. HyperlinkPath::encode copied every byte from 128 up as is, so a file with a 0xFF byte in its name produced an address that was not a valid URI, and the byte itself landed straight inside the OSC 8 sequence, where the spec only allows bytes from 32 to 126.

How we fixed it

Invalid bytes are percent-encoded

The loop now walks utf8_chunks(): valid chunks are encoded as before, with valid non-ASCII characters left alone, and every byte outside UTF-8 becomes %XX, for example bad%FF.txt. The encode_invalid_utf8 test covers single bad bytes, a truncated multibyte sequence and their mix with a valid é.

#3550

Merged change 1

  1. #3550 printer: fix hyperlink paths that are not valid UTF-8 Merged 21 November 2026

What it taught us

A fix is worth narrowing to the case the existing reasoning did not cover. Valid non-ASCII UTF-8 stays unencoded on purpose, because encoding it breaks file:// URLs on Windows, and we only encode the bytes that cannot appear in a URI.

More about this technology: Rust

Other projects we write code for

Describe your project.

A free quote comes back within an hour during working hours.