Commit graph

1869 commits

Author SHA1 Message Date
1f2d7aa99d minidom: Rework Prefixes internal structure
Change the mapping in Prefixes to Prefix -> Namespace instead of
Namespace -> Prefix. This allows us to not have duplicate prefixes
anymore, but requires us to store the prefix on Element. This prefix is
only taken as a hint anyway and used only when coming from the reader.

This commits also partially removes the possibility to add prefixes
when creating an Element via `Element::new`, `Element::builder` or
`Element::bare`. Proper errors should be added in the following commits.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-04-21 22:23:36 +02:00
429949102d minidom: remove unused Rc
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-04-21 22:23:36 +02:00
6308250c17 parsers: update for minidom API changes
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-04-21 22:23:36 +02:00
40b92d64e2 minidom: clarify meaning of Element.name (being the local name)
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-04-21 22:23:36 +02:00
171e7f1f34 minidom: ensure prefix is extracted out of provided name when creating Element
I would have liked to handle all of this in `Element::new` only, but I
also have to do it in `Element::builder` unfortunately because then
element builder then pushes prefixes it gathered itself.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-04-21 22:23:36 +02:00
f151306fbe minidom: forcing a namespace on Element. Stop requiring prefixes.
Below is what I think I did.

A few changes:
- Change prefixes to be something less important in the API.
- Rework the Element struct to force a namespace. In XMPP everything is
  namespaced.
- Remove parent ref on what was previously NamespaceSet and is now
  Prefixes.

More specifically this means `Element::new` has changed to require
`Element`'s new new properties as parameters. `Element::builder` and
`Element::bare` now require a namespace unconditionally.
`Element::prefix` has been removed.

This new API is based on the fact that prefixes are non-essential
(really just an implementation detail) and shouldn't be visible to the
user. It is possible nonetheless to set custom prefixes for
compatibility reasons with `ElementBuilder::prefix`. **A prefix is
firstly mapped to a namespace, and then attached to an element**, there
cannot be a prefix without a namespace.

Prefix inheritance is used if possible but for the case with no
prefix ("xmlns") to be reused, we only check custom prefixes declared on
the tag itself and not ascendants. If it's already used then we generate
prefixes (ns0, ns1, ..) checking on what has been declared on all
ascendants (plus of course those already set on the current tag).

Example API:

```rust
let mut elem = ElementBuilder("stream", "http://etherx.jabber.org/streams")
  .prefix(Some(String::from("stream")), "http://etherx.jabber.org/streams)
  .prefix(None, "jabber:client")
  .attr(..)
  .build();

assert_eq!(elem.ns(), String::from("http://etherx.jabber.org/streams"));
```

See also the few tests added in src/tests.

TODO: Fix inconsistencies wrt. "prefix:name" format provided as a name
when creating an Element with `Element::new` or `Element::bare`.
`Element::builder` already handles this as it should, splitting name and
prefix.
TODO: Change `Element::name` method to `Element::local_name` to make it
more explicit.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-04-21 22:23:36 +02:00
0b680a18e5
parsers: Fix jingle and jingle_rtp test_size for 32bit
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-04-05 19:05:12 +02:00
080c7b8c95 CI: Remove build stage
`cargo test` rebuilds all of it anyway.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-04-05 15:05:16 +02:00
5eeac93f67 CI: rename jobs to make it easier to read in gitlab
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-04-05 15:05:16 +02:00
20b224855c minidom: Remove NSChoice::None
Although it is still possible to create such elements, this is not a a
case that should happen in XMPP. Changing to API to prevent the creation
of these elements is next on the list.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-03-27 18:32:57 +00:00
Emmanuel Gil Peyrot
9737194b5e xmpp-parsers: Add MIX to the supported XEPs. 2020-03-27 19:19:43 +01:00
Emmanuel Gil Peyrot
048e49f786 xmpp-parsers: Add a MIX serialisation test. 2020-03-27 19:19:43 +01:00
Emmanuel Gil Peyrot
820fbbf08e xmpp-parsers: Add helper constructors for MIX. 2020-03-27 19:19:43 +01:00
Emmanuel Gil Peyrot
ad4c1f5b15 xmpp-parsers: Add a MIX parser. 2020-03-27 19:19:07 +01:00
5e7701f334
minidom: Remove remaining Comment bits in node
They were hidden behind the flag and not showing up in tests.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-03-26 23:21:50 +01:00
015d0007fc
minidom: Remove comments support. Forbid them as per XMPP RFC.
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-03-26 20:50:30 +01:00
Emmanuel Gil Peyrot
c154593fe5 Bump dependencies 2020-03-26 18:28:50 +01:00
f41b6bfd32
Use stable rustfmt
And install it as the container doesn't have it. Fortunately it's rather
quick (few seconds).

The previous nightly container apparently dropped rustfmt, which is
understandable as not all tools are available all the time. That's on
us.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-03-26 18:09:59 +01:00
476813a10a
CI: Allow nightly to fail
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-03-26 18:04:21 +01:00
Astro
a4325c787a tokio-xmpp: doc 2020-03-16 00:34:46 +01:00
Astro
b6828b9674 tokio-xmpp: remove obsolete TODOs 2020-03-16 00:11:52 +01:00
4ae9ab41ab
xmpp-rs: add env_logger in example
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-03-13 23:25:06 +01:00
Astro
7f25b4ef56 tokio-xmpp: update for futures-0.3 (100% API breakage) 2020-03-08 20:39:35 +01:00
Astro
23cb34e026 tokio-xmpp: rewrite for futures-0.3 2020-03-06 18:01:31 +01:00
Astro
bded964c38 tokio-xmpp: update dependency xml5ever 2020-03-01 00:40:45 +01:00
Emmanuel Gil Peyrot
04df9fde63 xmpp-parsers: Bump base64 to 0.11. 2020-02-28 01:28:57 +01:00
Emmanuel Gil Peyrot
944c4a0815 minidom: quick-xml::Error now implements Error without failure, so use it
Thanks pep.!
2020-02-28 01:28:54 +01:00
Emmanuel Gil Peyrot
09745829f1 client: Remove Result from Mechanism::initial(). 2020-02-25 23:31:29 +01:00
Emmanuel Gil Peyrot
21e9c8e660 Switch from the deprecated rand-os crate to getrandom. 2020-02-25 22:32:03 +01:00
280ce6c458
Readd global LICENSE file
Remove in 9c1654f59b by mistake.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-02-25 22:13:34 +01:00
89d92ced73 parsers: 0.17.0 release
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-02-15 02:27:26 +01:00
c5a813f6c5 jid: 0.9.0 release
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-02-15 02:27:26 +01:00
18d66edfe0 jid: Update Changelog
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-02-15 02:27:26 +01:00
043a0f257b
parsers: Update Changelog
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-02-15 01:50:09 +01:00
9c1654f59b
parsers: remove trailing whitespace
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-02-15 01:48:52 +01:00
6ee750ba11
minidom: 0.12.0 release
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-02-15 01:05:56 +01:00
3e7179c12f minidom: clarify/update changelog
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-02-15 00:52:26 +01:00
9511247d2f minidom: add license headers
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-02-15 00:52:26 +01:00
6c3332bc2f Add LICENSE file (MPL2) as all projects have the same
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-02-14 23:25:06 +01:00
676f861f72 minidom: Change license to MPL2. Closes #21
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-02-14 23:25:06 +01:00
c8538c18f5 minidom: Make explicit the focus on XMPP
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-02-14 23:12:02 +01:00
44eaa5a6ea tokio-xmpp: Prevent XmppCodec from producing invalid stanza
This bug was introduced by 2e97f4de2e, to
fix another bug where the parser would choke on whitespace.

The bug would manifest whenever a stanza was sent in different parts,
for example:
<< "<message "
<< "type='chat><body>foo</body></message>"

Would produce the following once parsed:
`<messagetype='chat'><body>foo</body></messagetype='chat'>`

This commit ensures this doesn't happen anymore (by not trimming
whitespaces before feeding the parser), and also ensures that
whitespaces are now handled at the correct layer.

The removal of xmpp_codec::test_lone_whitespace only happens because I'm
not sure if it's supposed to be here anymore. Maybe it should be at a
different layer? Or written differently?

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-01-22 01:25:15 +01:00
0377b5658a parsers: Remove dead get_ns methods
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-01-22 00:50:56 +01:00
fbb0edd93b parsers: cleanup warnings about errors and unused stuff
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2020-01-22 00:50:56 +01:00
Paul Fariello
c224133382 Add test for openpgp pubkey serialization 2020-01-21 17:23:08 +01:00
Paul Fariello
13afbfd099 Add test for jingle udp transport serialization 2020-01-21 16:59:22 +01:00
Paul Fariello
1432807f11 Add tests for cert management serialization 2020-01-21 16:53:56 +01:00
Paul Fariello
34a87e22a8 Fix fmt 2019-12-30 11:28:52 +01:00
Paul Fariello
8d246975d7 Add serialization test for sm failed element 2019-12-30 11:20:37 +01:00
Paul Fariello
6b14b593d3 Add serialization test for pubsub publish-options and options element 2019-12-30 11:20:37 +01:00