---
title: "ripgrep: hyperlinks for non-UTF-8 paths in Rust | VulCode"
description: "A fix in ripgrep, written in Rust: paths with bytes outside UTF-8 are percent-encoded in terminal hyperlinks, so the file:// address is a valid URI."
url: "https://vulcode.com/en/opensource/contributions/ripgrep"
lang: "en"
---

[All contributions](https://vulcode.com/en/opensource/contributions)

BurntSushi/ripgrep

# ripgrep

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

[See the repository](https://github.com/BurntSushi/ripgrep) [All contributions](https://vulcode.com/en/opensource/contributions)

- **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](https://github.com/BurntSushi/ripgrep/pull/3550)

## Merged change 1

- [#3550 printer: fix hyperlink paths that are not valid UTF-8 Merged 21 November 2026](https://github.com/BurntSushi/ripgrep/pull/3550)

## 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](https://vulcode.com/en/technologies/rust)

## Other projects we write code for

- [**Zed** Rust · 95,562 stars A fast code editor in Rust from the creators of Atom and Tree-sitter, with live multiplayer editing.](https://vulcode.com/en/opensource/contributions/zed)

- [**uv** Rust · 92,647 stars An extremely fast Python package and project manager written in Rust. It creates projects, installs dependencies and manages virtual environments.](https://vulcode.com/en/opensource/contributions/uv)

- [**Alacritty** Rust · 66,271 stars A cross-platform terminal emulator rendered with OpenGL, written in Rust and configured with a TOML file.](https://vulcode.com/en/opensource/contributions/alacritty)

- [**Gleam** Rust · 22,083 stars A friendly programming language for building type-safe, scalable systems. Its compiler is written in Rust.](https://vulcode.com/en/opensource/contributions/gleam)

- [**Sonic** Rust · 21,387 stars A lightweight full-text search backend in Rust, an alternative to Elasticsearch that runs in a few megabytes of RAM.](https://vulcode.com/en/opensource/contributions/sonic)

- [**Pagefind** Rust · 5,575 stars A Rust search engine for static sites that indexes the built site and only sends the needed parts of the index to the browser.](https://vulcode.com/en/opensource/contributions/pagefind)

## Describe your project.

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

### Rather skip the form?

Ask in the chat or write to us directly.

Open the chat

- **Email**: [hello@vulcode.com](mailto:hello@vulcode.com)
- **Phone**: [+48 576 043 920](tel:+48576043920)
- **Discord**: [discord.gg/vulcode](https://discord.gg/vulcode)
