mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-03 08:49:37 -06:00
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:
co-authored by
Claude Haiku 5.5
parent
bd920fc7de
commit
9a1b33bbfd
@@ -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}`"))),
|
||||
}
|
||||
|
||||
@@ -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:?}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user