parsers: do not do extensive XEP-0030 validation with disable-validation
Jonas Schäfer
created
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.
@@ -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)