Skip to content

Commit 12a07bb

Browse files
committed
disallow package types starting with digits
1 parent 057b434 commit 12a07bb

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

purl/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,10 @@ fn is_valid_package_type(package_type: &str) -> bool {
381381
// https://github.com/package-url/purl-spec/blob/master/PURL-SPECIFICATION.rst#rules-for-each-purl-component
382382
const ALLOWED_SPECIAL_CHARS: &[char] = &['.', '+', '-'];
383383
!package_type.is_empty()
384+
&& package_type.starts_with(|c: char| c.is_ascii_alphabetic())
384385
&& package_type
385386
.chars()
387+
.skip(1)
386388
.all(|c| c.is_ascii_alphanumeric() || ALLOWED_SPECIAL_CHARS.contains(&c))
387389
}
388390

0 commit comments

Comments
 (0)