Skip to content

Commit 68c59a5

Browse files
committed
fix(validator): enforce lowercase package name per spec PR WasmEdge#630
The spec updated interfacename grammar from <label> to <words>, confirming that package names must be lowercase-only kebab-case. Refs: WebAssembly/component-model#630 Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: LFsWang <tnst92002@gmail.com>
1 parent a5c894c commit 68c59a5

2 files changed

Lines changed: 5 additions & 13 deletions

File tree

lib/validator/component_name.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -581,13 +581,9 @@ Expect<ComponentName> ComponentName::parse(std::string_view Name) {
581581
return reportError("nested namespaces not supported yet"sv);
582582
}
583583

584-
// NOTE: The spec (Explainer.md:2550) uses <label> here, which allows
585-
// mixed-case kebab. The wasm-tools reference implementation enforces
586-
// lowercase, and the spec test naming.14.wasm expects rejection of
587-
// uppercase packages. We follow the spec grammar; if the spec updates
588-
// to <words>, this should be changed to isLowercaseKebabString.
589-
if (!tryReadKebab(Next, Package)) {
590-
return reportError("invalid package label in interface name"sv);
584+
// interfacename ::= <namespace> <words> <projection> ...
585+
if (!tryReadKebab(Next, Package) || !isLowercaseKebabString(Package)) {
586+
return reportError("invalid package in interface name"sv);
591587
}
592588

593589
Counter = 0;

test/component/ComponentRegressionTest.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,12 +1081,8 @@ TEST(ComponentNameParser, Semver) {
10811081
// Invalid versions.
10821082
EXPECT_FALSE(ComponentName::parse("ns:pkg/iface@01.2.3"sv));
10831083
EXPECT_FALSE(ComponentName::parse("ns:pkg/iface@abc"sv));
1084-
// Package is <label> per spec — allows mixed-case kebab.
1085-
// NOTE: wasm-tools enforces lowercase here; we follow the spec grammar.
1086-
// If the spec updates <label> to <words>, change these expectations.
1087-
EXPECT_TRUE(ComponentName::parse("a:B/c"sv));
1088-
EXPECT_TRUE(ComponentName::parse("ns:PKG/iface"sv));
1089-
// "Pkg" is NOT valid kebab (mixed case within fragment).
1084+
EXPECT_FALSE(ComponentName::parse("a:B/c"sv));
1085+
EXPECT_FALSE(ComponentName::parse("ns:PKG/iface"sv));
10901086
EXPECT_FALSE(ComponentName::parse("ns:Pkg/iface"sv));
10911087
EXPECT_FALSE(ComponentName::parse("ns:pkg/iface@"sv));
10921088
EXPECT_TRUE(ComponentName::parse("ns:pkg/iface@0.0.0"sv));

0 commit comments

Comments
 (0)