From e274b1da5bc50fb681c1e5e92bd7821dad25cd69 Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Tue, 24 Sep 2024 14:19:01 +0200 Subject: [PATCH] disallow dash in version --- src/recipe/custom_yaml.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/recipe/custom_yaml.rs b/src/recipe/custom_yaml.rs index f20f764b..51973bc8 100644 --- a/src/recipe/custom_yaml.rs +++ b/src/recipe/custom_yaml.rs @@ -1276,6 +1276,17 @@ impl TryConvertNode for RenderedNode { impl TryConvertNode for RenderedScalarNode { fn try_convert(&self, name: &str) -> Result> { + let s = self.as_str(); + if s.contains('-') { + // version is not allowed to contain a `-` + return Err(vec![_partialerror!( + *self.span(), + ErrorKind::InvalidValue((name.to_string(), "version cannot contain `-`".into())), + label = format!("version `{s}` cannot contain `-` "), + help = "replace the `-` with `_` or remove it" + )]); + } + VersionWithSource::from_str(self.as_str()) .map_err(|err| { _partialerror!(