diff --git a/zenoh-plugin-mqtt/src/config.rs b/zenoh-plugin-mqtt/src/config.rs index b074c0b..5f52612 100644 --- a/zenoh-plugin-mqtt/src/config.rs +++ b/zenoh-plugin-mqtt/src/config.rs @@ -129,10 +129,17 @@ fn deserialize_regex<'de, D>(deserializer: D) -> Result, D::Error> where D: Deserializer<'de>, { - let s: String = Deserialize::deserialize(deserializer)?; - Regex::new(&s) - .map(Some) - .map_err(|e| de::Error::custom(format!("Invalid regex 'allow={s}': {e}"))) + let s: Option = Deserialize::deserialize(deserializer)?; + + match s { + Some(s) => Regex::new(&s).map(Some).map_err(|e| { + de::Error::custom(format!( + r#"Invalid regex for 'allow' or 'deny': "{s}" - {e}"# + )) + }), + + None => Ok(None), + } } fn serialize_allow(v: &Option, serializer: S) -> Result