mirror of
https://github.com/NixOS/nix.git
synced 2025-11-18 00:12:43 +01:00
libfetchers: Remove badGitRefRegex and use libgit2 for reference validation
Fixes usage of `#` symbol in the reference name. This also seems to identify several deficiencies in the libgit2 refname validation code wrt to DEL symbol and a singular `@` symbol [1]. [1]: https://git-scm.com/docs/git-check-ref-format#_description
This commit is contained in:
parent
0b7f7e4b03
commit
e8e9376a7b
10 changed files with 154 additions and 19 deletions
|
|
@ -48,7 +48,7 @@ struct GitArchiveInputScheme : InputScheme
|
|||
if (size == 3) {
|
||||
if (std::regex_match(path[2], revRegex))
|
||||
rev = Hash::parseAny(path[2], HashAlgorithm::SHA1);
|
||||
else if (std::regex_match(path[2], refRegex))
|
||||
else if (isLegalRefName(path[2]))
|
||||
ref = path[2];
|
||||
else
|
||||
throw BadURL("in URL '%s', '%s' is not a commit hash or branch/tag name", url, path[2]);
|
||||
|
|
@ -61,7 +61,7 @@ struct GitArchiveInputScheme : InputScheme
|
|||
}
|
||||
}
|
||||
|
||||
if (std::regex_match(rs, refRegex)) {
|
||||
if (isLegalRefName(rs)) {
|
||||
ref = rs;
|
||||
} else {
|
||||
throw BadURL("in URL '%s', '%s' is not a branch/tag name", url, rs);
|
||||
|
|
@ -75,7 +75,7 @@ struct GitArchiveInputScheme : InputScheme
|
|||
throw BadURL("URL '%s' contains multiple commit hashes", url);
|
||||
rev = Hash::parseAny(value, HashAlgorithm::SHA1);
|
||||
} else if (name == "ref") {
|
||||
if (!std::regex_match(value, refRegex))
|
||||
if (!isLegalRefName(value))
|
||||
throw BadURL("URL '%s' contains an invalid branch/tag name", url);
|
||||
if (ref)
|
||||
throw BadURL("URL '%s' contains multiple branch/tag names", url);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue