Skip to content

libutil: Fix handling of unescaped spaces, quotes and shevrons in queries and fragments#13773

Merged
Mic92 merged 1 commit intoNixOS:masterfrom
xokdvium:quotes-fragment
Aug 17, 2025
Merged

libutil: Fix handling of unescaped spaces, quotes and shevrons in queries and fragments#13773
Mic92 merged 1 commit intoNixOS:masterfrom
xokdvium:quotes-fragment

Conversation

@xokdvium
Copy link
Copy Markdown
Contributor

Motivation

Turns out we didn't have tests for some of the important behavior introduced for flake reference fragments and url queries 1. This is rather important and is relied upon by existing tooling. This fixes up these exact cases before handing off the URL to the Boost.URL parser.

To the best of my knowledge this implements the same behavior as prior regex-based parser did 2:

fragmentRegex = "(?:" + pcharRegex + "|[/? \"^])*";
queryRegex = "(?:" + pcharRegex + "|[/? \"])*";

Context

Fixes #13772. Thankfully we didn't have a release with this refactoring yet.


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

…ries and fragments

Turns out we didn't have tests for some of the important behavior introduced
for flake reference fragments and url queries [1]. This is rather important
and is relied upon by existing tooling. This fixes up these exact cases before
handing off the URL to the Boost.URL parser.

To the best of my knowledge this implements the same behavior as prior regex-based
parser did [2]:

> fragmentRegex = "(?:" + pcharRegex + "|[/? \"^])*";
> queryRegex = "(?:" + pcharRegex + "|[/? \"])*";

[1]: 9c0a09f
[2]: https://github.com/NixOS/nix/blob/2.30.2/src/libutil/include/nix/util/url-parts.hh
@xokdvium xokdvium requested a review from edolstra as a code owner August 16, 2025 20:07
@xokdvium xokdvium requested review from Ericson2314 and Mic92 August 16, 2025 20:07
@xokdvium
Copy link
Copy Markdown
Contributor Author

cc @NobbZ

@NobbZ
Copy link
Copy Markdown
Contributor

NobbZ commented Aug 16, 2025

Yeah, this seems to fix the issue I have.

@Mic92 Mic92 merged commit 1cf0fe3 into NixOS:master Aug 17, 2025
14 checks passed
@xokdvium xokdvium deleted the quotes-fragment branch August 17, 2025 23:13
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

Successfully merging this pull request may close these issues.

fragments containing quotes are not parsed correctly anymore.

3 participants