From 07fc8d8fb8114ed68a518336db3233d6ce7a7c9c Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Tue, 24 Sep 2024 14:51:35 +0200 Subject: [PATCH] fix: disallow dash in version (#1065) --- 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 f20f764b1..51973bc8c 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!(