Package.Fetch: tighten up check for path outside root

This commit is contained in:
Andrew Kelley 2023-10-08 17:42:49 -07:00
parent 6d84caf727
commit 5e7c44a321
2 changed files with 4 additions and 3 deletions

View file

@ -257,7 +257,9 @@ pub fn run(f: *Fetch) RunError!void {
f.hash_tok,
try eb.addString("path-based dependencies are not hashed"),
);
if (std.mem.startsWith(u8, pkg_root.sub_path, "../")) {
if (std.mem.startsWith(u8, pkg_root.sub_path, "../") or
std.mem.eql(u8, pkg_root.sub_path, ".."))
{
return f.fail(
f.location_tok,
try eb.printString("dependency path outside project: '{}{s}'", .{

View file

@ -318,8 +318,7 @@ const Parse = struct {
for (array_init.ast.elements) |elem_node| {
const path_string = try parseString(p, elem_node);
const normalized = try std.fs.path.resolve(p.arena, &.{path_string});
try p.paths.put(p.gpa, normalized, {});
try p.paths.put(p.gpa, path_string, {});
}
}