Package.Manifest: enforce name limit of 32
This commit is contained in:
@@ -9,6 +9,7 @@ const Package = @import("../Package.zig");
|
||||
|
||||
pub const max_bytes = 10 * 1024 * 1024;
|
||||
pub const basename = "build.zig.zon";
|
||||
pub const max_name_len = 32;
|
||||
|
||||
pub const Dependency = struct {
|
||||
location: Location,
|
||||
@@ -365,6 +366,11 @@ const Parse = struct {
|
||||
if (!std.zig.isValidId(name))
|
||||
return fail(p, main_token, "name must be a valid bare zig identifier (hint: switch from string to enum literal)", .{});
|
||||
|
||||
if (name.len > max_name_len)
|
||||
return fail(p, main_token, "name '{s}' exceeds max length of {d}", .{
|
||||
std.zig.fmtId(name), max_name_len,
|
||||
});
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -375,6 +381,11 @@ const Parse = struct {
|
||||
if (mem.startsWith(u8, ident_name, "@"))
|
||||
return fail(p, main_token, "name must be a valid bare zig identifier", .{});
|
||||
|
||||
if (ident_name.len > max_name_len)
|
||||
return fail(p, main_token, "name '{s}' exceeds max length of {d}", .{
|
||||
std.zig.fmtId(ident_name), max_name_len,
|
||||
});
|
||||
|
||||
return ident_name;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user