Fix value validation
This commit is contained in:
@ -272,18 +272,17 @@ impl<'de> Deserialize<'de> for SecurePath {
|
|||||||
where
|
where
|
||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
{
|
{
|
||||||
let s = <Vec<String>>::deserialize(deserializer)?;
|
let s = <String>::deserialize(deserializer)?;
|
||||||
let k: String = s[0].to_string();
|
|
||||||
// A-Z a-z 0-9
|
// A-Z a-z 0-9
|
||||||
// . - _
|
// . - _
|
||||||
if k.chars()
|
if s.chars()
|
||||||
.all(|c| c.is_ascii_alphanumeric() || c == '.' || c == '-' || c == '_')
|
.all(|c| c.is_ascii_alphanumeric() || c == '.' || c == '-' || c == '_')
|
||||||
{
|
{
|
||||||
return Ok(SecurePath { data: k });
|
return Ok(SecurePath { data: s });
|
||||||
}
|
}
|
||||||
Err(serde::de::Error::custom(format!(
|
Err(serde::de::Error::custom(format!(
|
||||||
"Invalid value: {}",
|
"Invalid value: {}",
|
||||||
k.to_string()
|
s.to_string()
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user