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:
parent
0298caf97a
commit
37481fb8f6
1 changed files with 19 additions and 16 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue