| ... | @@ -4694,7 +4694,11 @@ pub fn importFile( | ... | @@ -4694,7 +4694,11 @@ pub fn importFile( |
| 4694 | const resolved_root_path = try std.fs.path.resolve(gpa, &[_][]const u8{cur_pkg_dir_path}); | 4694 | const resolved_root_path = try std.fs.path.resolve(gpa, &[_][]const u8{cur_pkg_dir_path}); |
| 4695 | defer gpa.free(resolved_root_path); | 4695 | defer gpa.free(resolved_root_path); |
| 4696 | | 4696 | |
| 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 | { |
| 4698 | return error.ImportOutsidePkgPath; | 4702 | return error.ImportOutsidePkgPath; |
| 4699 | } | 4703 | } |
| 4700 | // +1 for the directory separator here. | 4704 | // +1 for the directory separator here. |