parsers: do not do extensive XEP-0030 validation with disable-validation

Other additional checks are already gated by the absence of this
feature. As the MR to remove these checks altogether is still blocked,
this should serve as at least as an intermediate solution to anyone
affected by buggy remote implementations.
This commit is contained in:
Jonas Schäfer 2024-04-28 10:48:35 +02:00
parent 0298caf97a
commit 37481fb8f6

View file

@ -151,22 +151,25 @@ impl TryFrom<Element> for DiscoInfoResult {
}
}
if result.identities.is_empty() {
return Err(Error::ParseError(
"There must be at least one identity in disco#info.",
));
}
if result.features.is_empty() {
return Err(Error::ParseError(
"There must be at least one feature in disco#info.",
));
}
if !result.features.contains(&Feature {
var: ns::DISCO_INFO.to_owned(),
}) {
return Err(Error::ParseError(
"disco#info feature not present in disco#info.",
));
#[cfg(not(feature = "disable-validation"))]
{
if result.identities.is_empty() {
return Err(Error::ParseError(
"There must be at least one identity in disco#info.",
));
}
if result.features.is_empty() {
return Err(Error::ParseError(
"There must be at least one feature in disco#info.",
));
}
if !result.features.contains(&Feature {
var: ns::DISCO_INFO.to_owned(),
}) {
return Err(Error::ParseError(
"disco#info feature not present in disco#info.",
));
}
}
Ok(result)