Skip to content

Commit 9d91b02

Browse files
committed
Revert "xmpp-parsers: Remove optional child from sm element"
This reverts commit 0a1b291 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 (4e0cd5d) would be useful to support then, as it might also be found in the wild.
1 parent 3e794d3 commit 9d91b02

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

parsers/ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ XXXX-YY-ZZ RELEASER <[email protected]>
109109
- JSON Containers (XEP-0335) (!546)
110110
- Verifying HTTP Requests via XMPP (XEP-0070)
111111
* Improvements:
112+
- Add support for undocumented `<optional/> in XEP-0198 feature
113+
advertisment, for compatibility with servers in the wild.
112114
- Add support application-specific error conditions in XEP-0198
113115
- Keep unsupported vCard elements as `minidom::Element`, so that they
114116
get serialized back instead of being dropped. We now also test for

parsers/src/sasl2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ mod tests {
269269

270270
let inline = auth.inline.unwrap();
271271
assert_eq!(inline.bind2.unwrap().inline_features.len(), 0);
272-
assert_eq!(inline.sm.unwrap(), StreamManagement);
272+
assert_eq!(inline.sm.unwrap(), StreamManagement { optional: false });
273273
assert_eq!(inline.payloads.len(), 0);
274274
}
275275

parsers/src/sm.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,13 @@ pub struct Resumed {
136136
/// Represents availability of Stream Management in `<stream:features/>`.
137137
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
138138
#[xml(namespace = ns::SM, name = "sm")]
139-
pub struct StreamManagement;
139+
pub struct StreamManagement {
140+
/// Undocumented `<optional/>` flag.
141+
// TODO: Remove this flag once servers in the wild have been updated to not send it, as it is
142+
// completely undocumented in XEP-0198, only appearing in the XML Schema before 1.6.3.
143+
#[xml(flag)]
144+
pub optional: bool,
145+
}
140146

141147
/// Application-specific error condition to use when the peer acknowledges
142148
/// more stanzas than the local side has sent.
@@ -215,7 +221,7 @@ mod tests {
215221
assert_size!(R, 0);
216222
assert_size!(Resume, 16);
217223
assert_size!(Resumed, 16);
218-
assert_size!(StreamManagement, 0);
224+
assert_size!(StreamManagement, 1);
219225
assert_size!(HandledCountTooHigh, 8);
220226
}
221227

@@ -230,7 +236,7 @@ mod tests {
230236
assert_size!(R, 0);
231237
assert_size!(Resume, 32);
232238
assert_size!(Resumed, 32);
233-
assert_size!(StreamManagement, 0);
239+
assert_size!(StreamManagement, 1);
234240
assert_size!(HandledCountTooHigh, 8);
235241
}
236242

0 commit comments

Comments
 (0)