Tighten parsing for drv files and pathinfo

This commit is contained in:
Carlo Nucera 2020-07-02 11:57:21 -04:00
parent b6b10b1d4c
commit 1fc835aa22
2 changed files with 4 additions and 4 deletions

View file

@ -68,7 +68,7 @@ ContentAddress parseContentAddress(std::string_view rawCa) {
throw Error("text content address hash should use %s, but instead uses %s",
printHashType(htSHA256), printHashType(hashType));
return TextHash {
.hash = Hash::parseAny(rest, std::move(hashType)),
.hash = Hash::parseNonSRIUnprefixed(rest, std::move(hashType)),
};
} else if (prefix == "fixed") {
// Parse method
@ -80,7 +80,7 @@ ContentAddress parseContentAddress(std::string_view rawCa) {
HashType hashType = parseHashType_();
return FixedOutputHash {
.method = method,
.hash = Hash::parseAny(rest, std::move(hashType)),
.hash = Hash::parseNonSRIUnprefixed(rest, std::move(hashType)),
};
} else
throw UsageError("content address prefix \"%s\" is unrecognized. Recogonized prefixes are \"text\" or \"fixed\"", prefix);

View file

@ -118,7 +118,7 @@ static DerivationOutput parseDerivationOutput(const Store & store, istringstream
const HashType hashType = parseHashType(hashAlgo);
fsh = FixedOutputHash {
.method = std::move(method),
.hash = Hash::parseAny(hash, hashType),
.hash = Hash::parseNonSRIUnprefixed(hash, hashType),
};
}
@ -416,7 +416,7 @@ static DerivationOutput readDerivationOutput(Source & in, const Store & store)
auto hashType = parseHashType(hashAlgo);
fsh = FixedOutputHash {
.method = std::move(method),
.hash = Hash::parseAny(hash, hashType),
.hash = Hash::parseNonSRIUnprefixed(hash, hashType),
};
}