authorgravatar for lord@mzte.deLordMZTE <lord@mzte.de> 2022-07-01 12:21:06+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-07-27 18:17:07+03:00
log1110eafe9bd19ff69e9a7e488a7e9613fa909aeb
treead4477fc92824e0f4e8acdb5edb31809931206ac
parentbaafb8a491c296fbf434c8cf44d9485e8f2c729c

Module: fix error message importing file starting with root path


1 files changed, 5 insertions(+), 1 deletions(-)

src/Module.zig+5-1
......@@ -4694,7 +4694,11 @@ pub fn importFile(
46944694 const resolved_root_path = try std.fs.path.resolve(gpa, &[_][]const u8{cur_pkg_dir_path});
46954695 defer gpa.free(resolved_root_path);
46964696
4697 if (!mem.startsWith(u8, resolved_path, resolved_root_path)) {
4697 if (!mem.startsWith(u8, resolved_path, resolved_root_path) or
4698 // This prevents this check from triggering when the name of the
4699 // imported file starts with the root path's directory name.
4700 mem.indexOfAny(u8, &.{resolved_path[resolved_root_path.len]}, "/\\") == null)
4701 {
46984702 return error.ImportOutsidePkgPath;
46994703 }
47004704 // +1 for the directory separator here.