jid: Validate domains against idna

The idna crate validates against UTS 46, which supports domains using
either IDNA2003 or IDNA2008.  This allows us to support both old and
new internationalized domain names.

This dependency isn’t a new one in the tree, as hickory-proto, url and
tokio-xmpp all were already depending on it.

There are a bunch of other checks that have to be performed, this is
inspired by slixmpp’s JID implementation.
This commit is contained in:
Emmanuel Gil Peyrot 2025-02-05 18:26:48 +01:00
commit 2a2f532c80
5 changed files with 95 additions and 28 deletions

View file

@ -3,6 +3,8 @@ Version NEXT:
- Add missing check for JIDs with too many `@` before the resource, such as
`a@b@c` or `a@b@c/d` which should clearly be invalid. The new error it
produces is named `TooManyAts`.
- domainparts are now checked much more in-depth, using the idna crate and
various custom rules.
Version 0.11.1, release 2024-07-23:
* Breaking: