aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorLordMZTE <lord@mzte.de>2022-07-01 12:21:06 +0200
committerVeikka Tuominen <git@vexu.eu>2022-07-27 18:17:07 +0300
commit1110eafe9bd19ff69e9a7e488a7e9613fa909aeb (patch)
treead4477fc92824e0f4e8acdb5edb31809931206ac /src/Module.zig
parentbaafb8a491c296fbf434c8cf44d9485e8f2c729c (diff)
downloadzig-1110eafe9bd19ff69e9a7e488a7e9613fa909aeb.tar.gz
zig-1110eafe9bd19ff69e9a7e488a7e9613fa909aeb.zip
Module: fix error message importing file starting with root path
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Module.zig b/src/Module.zig
index 8bb5a94c17..85cc0f14b9 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -4694,7 +4694,11 @@ pub fn importFile(
const resolved_root_path = try std.fs.path.resolve(gpa, &[_][]const u8{cur_pkg_dir_path});
defer gpa.free(resolved_root_path);
- if (!mem.startsWith(u8, resolved_path, resolved_root_path)) {
+ if (!mem.startsWith(u8, resolved_path, resolved_root_path) or
+ // This prevents this check from triggering when the name of the
+ // imported file starts with the root path's directory name.
+ mem.indexOfAny(u8, &.{resolved_path[resolved_root_path.len]}, "/\\") == null)
+ {
return error.ImportOutsidePkgPath;
}
// +1 for the directory separator here.