Commit graph xmpp-rs/tokio-xmpp/src/xmlstream
Author SHA1 Message Date
Saarko
7c87d879d8 parsers: fix text field namespacing in StreamError
skip-changelog
2025-08-07 12:43:21 +00:00
Jonas Schäfer
e438813fb2 tokio_xmpp: properly process <stream:error/> while waiting for features
Before this, a stream error would not be readable by user code, as the
`recv_features()` function would not even attempt to parse it. This
change allows application code to react to stream errors which are
received before stream features are received.

skip-changelog, because there's no release with the xmlstream module
yet.
2025-07-13 12:53:43 +02:00
Jonas Schäfer
51ce661f8d tokio-xmpp: do not discard XmlLangStack when boxing the stream
The stream may have read some data already (such as the stream
header). When initially writing this code, I had missed that we do
actually also carry the parser state over: I misread the
AsyncReader::wrap(..) command as something like AsyncReader::new, i.e.
starting off with fresh parser state, so I assumed that we need a fresh
XmlLangStack, too.

This is wrong: `p` comes from `self.parser.into_inner()` above and is
the parser state, so we need to carry the lang stack along, as well.

This fixes:

```
thread 'tokio-runtime-worker' panicked at […]/rxml-0.13.1/src/xml_lang.rs:87:13:
pop from empty XmlLangStack
```

happening during stream shutdown. The panic was first reported by
@ppjet6, so thanks for that and the keen eye.

skip-changelog, because the bug has not been released yet.
2025-05-03 17:41:13 +02:00
Jonas Schäfer
cffb5e7e65 xso: make Context use a builder-like pattern
That way, we can (hopefully) add more fields in the future without
breaking stuff.

I don't yet know what such fields could be, though.
2025-04-27 14:08:38 +02:00
Jonas Schäfer
d9a21dd8c9 Track xml:lang throughout parsing 2025-04-22 17:55:44 +02:00
Link Mauve
a8c66bc783 minidom, tokio-xmpp: Use Option::as_deref()
This simplifies the Option::as_ref().map(|foo| &**foo) pattern a lot.

skip-changelog: Completely internal change.
2025-04-19 00:06:13 +02:00
Maxime “pep” Buquet
23c947d081 tokio-xmpp: clippy run
skip-changelog

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2025-04-08 13:57:21 +02:00
5bc94dce95 tokio_xmpp: Replace std::io calls with use std::io 2024-12-19 20:51:57 +01:00
1ce2f894aa tokio_xmpp: Replace std stuff with alloc/core stuff 2024-12-19 20:45:36 +01:00
Jonas Schäfer
80f899daa0 tokio_xmpp: implement high-level, resilient stanza stream 2024-12-17 18:16:02 +01:00
Jonas Schäfer
56ce57ecde xmlstream: use Stanza for XmppStreamElement
Oftentimes, Stanza is at hand anyway, so this saves some typing.
2024-12-17 16:12:56 +01:00
Jonas Schäfer
c6f928d5c8 xmlstream: make sink implementation generic
This allows to use any serialisable type. The advantage is that moves
and clones are avoided (which would otherwise be needed to construct
e.g. a XmppStreamElement from a Stanza or Message).
2024-12-17 16:12:56 +01:00
Jonas Schäfer
519718d9b5 xmlstream: add support for boxing the transport
This is useful in situations where we don't want to care about the
specific type of the underlying transport.
2024-12-17 16:12:56 +01:00
Jonas Schäfer
2388f23b4e xmlstream: support receiving stream errors 2024-12-17 16:12:56 +01:00
Alvaro Parker
347e8d6f17 Impl Error for ReadError 2024-09-20 15:17:54 -03:00
Alvaro Parker
904bdeae11 add debug to StreamHeader 2024-09-17 12:07:06 -03:00
Alvaro Parker
2ff89a9e42 fix typos 2024-09-16 18:29:44 -03:00
Emmanuel Gil Peyrot
425be4bef4 tokio-xmpp: Improve highlight_xml()
First switch to LazyLock from OnceLock, to simplify the code.

Then concatenate the colour reset escape code instead of using
format!(), since the vast majority of those strings have more capacity
than their length it will avoid a reallocation in most cases.
2024-09-01 12:32:50 +02:00
Jonas Schäfer
263839a5f8 xmlstream: add tests to capture thingy
This would've caught the embarrassing error made in the previous commit.
2024-09-01 09:07:34 +00:00
Jonas Schäfer
c795921631 xmlstream: fix crash
This happened when (a bit too hastily) applying suggestions from a
review.
2024-09-01 09:07:34 +00:00
Jonas Schäfer
ce4b739026 xmlstream: allow simplex stream shutdown
Unlike poll_close, poll_shutdown will only kill the sending side of the
stream. This is relevant to perform a fully clean shutdown procedure in
XMPP.
2024-09-01 10:02:36 +02:00
Jonas Schäfer
4cfe4f8429 xmlstream: implement simple timeout logic
This allows to detect and handle dying streams without getting stuck
forever.

Timeouts are always wrong, though, so we put the burden of choosing the
right values (mostly) on the creator of a stream.
2024-09-01 10:02:36 +02:00
Jonas Schäfer
960fd782bd xmlstream: fix clean shutdown sequence
Without the early return in XmlStream::poll_next in case of the stream
footer, the read state gets recreated and the logic at the top of that
function to actually handle stream shutdown gracefully is never
triggered.

Also that logic was incorrect; the correct behaviour is to wait for the
true EOF.
2024-09-01 10:02:36 +02:00
Jonas Schäfer
efc859abc0 xmlstream: re-introduce syntax-highlit logging of XML stream I/O 2024-09-01 10:02:36 +02:00
Jonas Schäfer
c85c98b0bf xmlstream: improve responder-side of stream resets
This makes the stream resets a lot safer, by preventing the forbidden
send-read-reset combination of events: the reset function on the
responder side now takes the element to send right before the reset,
enforcing a send-reset pattern.
2024-08-29 16:47:13 +02:00
Jonas Schäfer
ab10e30ac0 Port crates to use new XSO-based xmlstream 2024-08-29 16:47:13 +02:00
Jonas Schäfer
7cfda820a6 xmlstream: introduce XMPP specifics 2024-08-29 16:43:20 +02:00
Jonas Schäfer
2c944ebbf8 xmlstream: add access to inner stream 2024-08-29 16:43:06 +02:00
Jonas Schäfer
2931df22db xmlstream: split initiation reset in two phases 2024-08-29 16:43:00 +02:00
Jonas Schäfer
c723897326 tokio_xmpp: introduce xmlstream module
This module provides XSO-based parsing, proper typestates and will
soon replace the proto module.
2024-08-29 16:42:57 +02:00