Reject signed major in plugin manifest api version string (#1853)

Found while testing crates/plugin/src/manifest.rs:70 (api_from_number_or_string, the Api::Text arm)

Co-authored-by: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
NetterSilver
2026-11-01 23:49:26 -05:00
committed by GitHub
co-authored by Claude Haiku 5.5
parent bd920fc7de
commit 9a1b33bbfd
2 changed files with 8 additions and 0 deletions
+1
View File
@@ -77,6 +77,7 @@ fn api_from_number_or_string<'de, D: serde::Deserializer<'de>>(d: D) -> Result<u
.trim()
.split('.')
.next()
.filter(|major| !major.is_empty() && major.bytes().all(|b| b.is_ascii_digit()))
.and_then(|major| major.parse().ok())
.ok_or_else(|| serde::de::Error::custom(format!("invalid api version `{s}`"))),
}
+7
View File
@@ -472,3 +472,10 @@ fn api_may_be_a_version_string() {
assert!(manifest(json!({"api": format!("{}.0.0", crate::API_VERSION + 1)})).is_err());
assert!(manifest(json!({"api": "x"})).is_err());
}
#[test]
fn api_version_string_rejects_signs() {
for bad in ["+2.0.0", "-1.0.0", "+2", ""] {
assert!(manifest(json!({"api": bad})).is_err(), "accepted {bad:?}");
}
}