diff options
author | Delan Azabani <delan@azabani.com> | 2024-06-22 23:00:59 +0800 |
---|---|---|
committer | Delan Azabani <delan@azabani.com> | 2024-06-29 05:11:31 +0000 |
commit | b2944d93a6d95810f0aef09e9ac44b95e2712554 (patch) | |
tree | 90a3c92b959aa27b742c7b6423c0337dd8a5f869 /src/libutil/url-parts.hh | |
parent | 5dc85e8b72d1ba433f69200537146275ff1c4a03 (diff) |
Reject fully-qualified URLs in 'from' argument of `nix registry add`
We previously allowed you to map any flake URL to any other flake URL,
including shorthand flakerefs, indirect flake URLs like `flake:nixpkgs`,
direct flake URLs like `github:NixOS/nixpkgs`, or local paths.
But flake registry entries mapping from direct flake URLs often come
from swapping the 'from' and 'to' arguments by accident, and even when
created intentionally, they may not actually work correctly.
This patch rejects those URLs (and fully-qualified flake: URLs), making
it harder to swap the arguments by accident.
Fixes #181.
Change-Id: I24713643a534166c052719b8770a4edfcfdb8cf3
Diffstat (limited to 'src/libutil/url-parts.hh')
-rw-r--r-- | src/libutil/url-parts.hh | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/libutil/url-parts.hh b/src/libutil/url-parts.hh index 6efcc7e50..1f570567c 100644 --- a/src/libutil/url-parts.hh +++ b/src/libutil/url-parts.hh @@ -46,4 +46,7 @@ const static std::string refAndOrRevRegex = "(?:(" + revRegexS + ")|(?:(" + refR const static std::string flakeIdRegexS = "[a-zA-Z][a-zA-Z0-9_-]*"; extern std::regex flakeIdRegex; +const static std::string flakeShorthandRegexS = "((" + flakeIdRegexS + ")(?:/(?:" + refAndOrRevRegex + "))?)"; +extern std::regex flakeShorthandRegex; + } |