Skip to content

Commit c63ce14

Browse files
committed
Fix issue where crates.io allowed the plus sign in crate names
1 parent 95ed663 commit c63ce14

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/models/krate.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ impl Crate {
261261
}
262262

263263
fn valid_ident(name: &str) -> bool {
264-
Self::valid_feature_name(name)
264+
Self::valid_feature_prefix(name)
265265
&& name
266266
.chars()
267267
.next()
@@ -599,6 +599,17 @@ mod tests {
599599
None
600600
);
601601
}
602+
603+
#[test]
604+
fn valid_name() {
605+
assert!(Crate::valid_name("foo"));
606+
assert!(!Crate::valid_name("京"));
607+
assert!(!Crate::valid_name(""));
608+
assert!(!Crate::valid_name("💝"));
609+
assert!(Crate::valid_name("foo_underscore"));
610+
assert!(Crate::valid_name("foo-dash"));
611+
assert!(!Crate::valid_name("foo+plus"));
612+
}
602613
}
603614

604615
pub trait CrateVersions {

0 commit comments

Comments
 (0)