File tree Expand file tree Collapse file tree 3 files changed +36
-3
lines changed
crates/wasmparser/src/validator
snapshots/local/component-model/naming.wast Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -627,9 +627,9 @@ impl<'a> ComponentNameParser<'a> {
627627 // pkgpath ::= <namespace>+ <label> <projection>*
628628 fn pkg_path ( & mut self , require_projection : bool ) -> Result < ( ) > {
629629 // There must be at least one package namespace
630- self . take_kebab ( ) ?;
630+ self . take_lowercase_kebab ( ) ?;
631631 self . expect_str ( ":" ) ?;
632- self . take_kebab ( ) ?;
632+ self . take_lowercase_kebab ( ) ?;
633633
634634 if self
635635 . features
@@ -638,7 +638,7 @@ impl<'a> ComponentNameParser<'a> {
638638 // Take the remaining package namespaces and name
639639 while self . next . starts_with ( ':' ) {
640640 self . expect_str ( ":" ) ?;
641- self . take_kebab ( ) ?;
641+ self . take_lowercase_kebab ( ) ?;
642642 }
643643 }
644644
@@ -823,6 +823,17 @@ impl<'a> ComponentNameParser<'a> {
823823 . unwrap_or_else ( || self . expect_kebab ( ) )
824824 }
825825
826+ fn take_lowercase_kebab ( & mut self ) -> Result < & ' a KebabStr > {
827+ let kebab = self . take_kebab ( ) ?;
828+ if let Some ( c) = kebab. chars ( ) . find ( |c| * c != '-' && !c. is_lowercase ( ) ) {
829+ bail ! (
830+ self . offset,
831+ "character `{c}` is not lowercase in package name/namespace"
832+ ) ;
833+ }
834+ Ok ( kebab)
835+ }
836+
826837 fn expect_kebab ( & mut self ) -> Result < & ' a KebabStr > {
827838 let s = self . take_rest ( ) ;
828839 self . kebab ( s)
Original file line number Diff line number Diff line change 9797 )
9898 " `DOWn` is not in kebab case"
9999)
100+
101+ (assert_invalid
102+ (component
103+ (instance (import " A:b/c" ))
104+ )
105+ " character `A` is not lowercase in package name/namespace"
106+ )
107+ (assert_invalid
108+ (component
109+ (instance (import " a:B/c" ))
110+ )
111+ " character `B` is not lowercase in package name/namespace"
112+ )
113+ (component
114+ (instance (import " a:b/c" ))
115+ )
Original file line number Diff line number Diff line change 1+ (component
2+ (type (;0;)
3+ (instance)
4+ )
5+ (import "a:b/c" (instance (;0;) (type 0)))
6+ )
You can’t perform that action at this time.
0 commit comments