Revert "xmpp-parsers: Remove optional child from sm element"

This reverts commit 0a1b291574 once again.

This is currently required to connect to Prosody, otherwise the parser
will choke on the extra undocumented child.

I still wonder if required (4e0cd5d96b)
would be useful to support then, as it might also be found in the wild.
This commit is contained in:
Link Mauve 2025-09-08 11:29:57 +02:00
commit 9d91b02dfd
3 changed files with 12 additions and 4 deletions

View file

@ -109,6 +109,8 @@ XXXX-YY-ZZ RELEASER <admin@example.com>
- JSON Containers (XEP-0335) (!546)
- Verifying HTTP Requests via XMPP (XEP-0070)
* Improvements:
- Add support for undocumented `<optional/> in XEP-0198 feature
advertisment, for compatibility with servers in the wild.
- Add support application-specific error conditions in XEP-0198
- Keep unsupported vCard elements as `minidom::Element`, so that they
get serialized back instead of being dropped. We now also test for

View file

@ -269,7 +269,7 @@ mod tests {
let inline = auth.inline.unwrap();
assert_eq!(inline.bind2.unwrap().inline_features.len(), 0);
assert_eq!(inline.sm.unwrap(), StreamManagement);
assert_eq!(inline.sm.unwrap(), StreamManagement { optional: false });
assert_eq!(inline.payloads.len(), 0);
}

View file

@ -136,7 +136,13 @@ pub struct Resumed {
/// Represents availability of Stream Management in `<stream:features/>`.
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
#[xml(namespace = ns::SM, name = "sm")]
pub struct StreamManagement;
pub struct StreamManagement {
/// Undocumented `<optional/>` flag.
// TODO: Remove this flag once servers in the wild have been updated to not send it, as it is
// completely undocumented in XEP-0198, only appearing in the XMLSchema before 1.6.3.
#[xml(flag)]
pub optional: bool,
}
/// Application-specific error condition to use when the peer acknowledges
/// more stanzas than the local side has sent.
@ -215,7 +221,7 @@ mod tests {
assert_size!(R, 0);
assert_size!(Resume, 16);
assert_size!(Resumed, 16);
assert_size!(StreamManagement, 0);
assert_size!(StreamManagement, 1);
assert_size!(HandledCountTooHigh, 8);
}
@ -230,7 +236,7 @@ mod tests {
assert_size!(R, 0);
assert_size!(Resume, 32);
assert_size!(Resumed, 32);
assert_size!(StreamManagement, 0);
assert_size!(StreamManagement, 1);
assert_size!(HandledCountTooHigh, 8);
}