disallow upper case letters in versions

This commit is contained in:
John Turner
2025-10-24 21:40:14 -04:00
parent aa0d4edc57
commit ccf7aeb98d

View File

@@ -51,7 +51,9 @@ pub fn version<'a>() -> impl Parser<&'a str, Output = Version> {
let rev = version_number().preceded_by(tag("-r"));
numbers
.and(opt(r#if(|c: &char| c.is_ascii_alphabetic())))
.and(opt(r#if(|c: &char| {
c.is_ascii_alphabetic() && c.is_ascii_lowercase()
})))
.and(opt(suffixes.preceded_by(tag("_"))))
.and(opt(rev))
.map(|(((numbers, letter), suffixes), rev)| Version {
@@ -287,4 +289,11 @@ mod test {
atom().check_finished(it).unwrap();
}
#[test]
fn test_version_with_uppercase_letter() {
let it = InputIter::new("foo/bar-1.0.0V");
assert!(atom().check_finished(it).is_err());
}
}