mirror of
https://github.com/NixOS/nix
synced 2025-06-29 14:53:16 +02:00
Don't allow appending a non-absolute path to the root of a source tree
This avoids an inconsistency where a '/' is implicitly inserted when you append to the root of a source tree, but not when you append to any other path.
This commit is contained in:
parent
d162222f25
commit
6d104bbbac
2 changed files with 10 additions and 1 deletions
|
@ -1998,6 +1998,11 @@ void ExprConcatStrings::eval(EvalState & state, Env & env, Value & v)
|
|||
} else if (firstType == nPath) {
|
||||
if (!first) {
|
||||
auto part = state.coerceToString(i_pos, *vTmp, context, false, false);
|
||||
if (sSize <= 1 && !hasPrefix(*part, "/"))
|
||||
state.throwEvalError(i_pos,
|
||||
"cannot append non-absolute path '%1%' to '%2%' (hint: change it to '/%1%')",
|
||||
(std::string) *part, accessor->root().to_string(),
|
||||
env, *this);
|
||||
sSize += part->size();
|
||||
s.emplace_back(std::move(part));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue