From 30200e188316b6ca00b296de2c53eea3ec6fef64 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 22 Apr 2024 14:47:29 -0500 Subject: [PATCH] Fix allowing numerals in package names (#1509) This fixes a mistake in #1505 where numerals were disallowed in package names. --- crates/wasmparser/src/validator/names.rs | 5 ++++- tests/local/component-model/naming.wast | 1 + tests/snapshots/local/component-model/naming.wast/16.print | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/wasmparser/src/validator/names.rs b/crates/wasmparser/src/validator/names.rs index 940deb6273..52d61ecb93 100644 --- a/crates/wasmparser/src/validator/names.rs +++ b/crates/wasmparser/src/validator/names.rs @@ -825,7 +825,10 @@ impl<'a> ComponentNameParser<'a> { fn take_lowercase_kebab(&mut self) -> Result<&'a KebabStr> { let kebab = self.take_kebab()?; - if let Some(c) = kebab.chars().find(|c| *c != '-' && !c.is_lowercase()) { + if let Some(c) = kebab + .chars() + .find(|c| c.is_alphabetic() && !c.is_lowercase()) + { bail!( self.offset, "character `{c}` is not lowercase in package name/namespace" diff --git a/tests/local/component-model/naming.wast b/tests/local/component-model/naming.wast index c4b42243d5..34756d29b0 100644 --- a/tests/local/component-model/naming.wast +++ b/tests/local/component-model/naming.wast @@ -112,4 +112,5 @@ ) (component (instance (import "a:b/c")) + (instance (import "a1:b1/c")) ) diff --git a/tests/snapshots/local/component-model/naming.wast/16.print b/tests/snapshots/local/component-model/naming.wast/16.print index 30c0b0ad31..bf4c7d129d 100644 --- a/tests/snapshots/local/component-model/naming.wast/16.print +++ b/tests/snapshots/local/component-model/naming.wast/16.print @@ -3,4 +3,8 @@ (instance) ) (import "a:b/c" (instance (;0;) (type 0))) + (type (;1;) + (instance) + ) + (import "a1:b1/c" (instance (;1;) (type 1))) )