| author | |
| committer | |
| log | 1fd95fc00519ee44de94fa5b73ca7a3285b92149 |
| tree | c14672df5650d18990d430b4272c9b1a8ee31c1d |
| parent | 29156de12022732cb90b5bc5f5a0e33bf25d894b |
This prevents bogus "error: file exists in multiple modules" errors due
to file paths looking like:
```
note: root of module foo/freetype/
note: root of module foo/fontconfig/../freetype/
```
It also enables checking for dependency paths outside the root package.2 files changed, 15 insertions(+), 1 deletions(-)
src/Package.zig+8| ... | ... | @@ -30,6 +30,14 @@ pub const Path = struct { |
| 30 | 30 | }; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | pub fn resolvePosix(p: Path, arena: Allocator, sub_path: []const u8) Allocator.Error!Path { | |
| 34 | if (sub_path.len == 0) return p; | |
| 35 | return .{ | |
| 36 | .root_dir = p.root_dir, | |
| 37 | .sub_path = try fs.path.resolvePosix(arena, &.{ p.sub_path, sub_path }), | |
| 38 | }; | |
| 39 | } | |
| 40 | ||
| 33 | 41 | pub fn joinString(p: Path, allocator: Allocator, sub_path: []const u8) Allocator.Error![]u8 { |
| 34 | 42 | const parts: []const []const u8 = |
| 35 | 43 | if (p.sub_path.len == 0) &.{sub_path} else &.{ p.sub_path, sub_path }; |
src/Package/Fetch.zig+7-1| ... | ... | @@ -248,7 +248,13 @@ pub fn run(f: *Fetch) RunError!void { |
| 248 | 248 | f.hash_tok, |
| 249 | 249 | try eb.addString("path-based dependencies are not hashed"), |
| 250 | 250 | ); |
| 251 | f.package_root = try f.parent_package_root.join(arena, sub_path); | |
| 251 | f.package_root = try f.parent_package_root.resolvePosix(arena, sub_path); | |
| 252 | if (std.mem.startsWith(u8, f.package_root.sub_path, "../")) { | |
| 253 | return f.fail( | |
| 254 | f.location_tok, | |
| 255 | try eb.addString("dependency path outside package"), | |
| 256 | ); | |
| 257 | } | |
| 252 | 258 | try loadManifest(f, f.package_root); |
| 253 | 259 | try checkBuildFileExistence(f); |
| 254 | 260 | if (!f.job_queue.recursive) return; |