1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-18 00:12:43 +01:00

Fix ParsedURL handling of %2F in URL paths

See the new extensive doxygen in `url.hh`.
This fixes fetching gitlab: flakes.

Paths are now stored as a std::vector of individual path
segments, which can themselves contain path separators '/' (%2F).
This is necessary to make the Gitlab's /projects/ API work.

Co-authored-by: John Ericson <John.Ericson@Obsidian.Systems>
Co-authored-by: Sergei Zimmerman <sergei@zimmerman.foo>
This commit is contained in:
Jörg Thalheim 2025-08-26 12:49:28 +02:00 committed by Sergei Zimmerman
parent 6839f3de55
commit c436b7a32a
No known key found for this signature in database
19 changed files with 446 additions and 117 deletions

View file

@ -38,7 +38,7 @@ struct GitArchiveInputScheme : InputScheme
if (url.scheme != schemeName())
return {};
auto path = tokenizeString<std::vector<std::string>>(url.path, "/");
const auto & path = url.path;
std::optional<Hash> rev;
std::optional<std::string> ref;
@ -139,12 +139,12 @@ struct GitArchiveInputScheme : InputScheme
auto repo = getStrAttr(input.attrs, "repo");
auto ref = input.getRef();
auto rev = input.getRev();
auto path = owner + "/" + repo;
std::vector<std::string> path{owner, repo};
assert(!(ref && rev));
if (ref)
path += "/" + *ref;
path.push_back(*ref);
if (rev)
path += "/" + rev->to_string(HashFormat::Base16, false);
path.push_back(rev->to_string(HashFormat::Base16, false));
auto url = ParsedURL{
.scheme = std::string{schemeName()},
.path = path,