Mercurial > prosody-hg
diff spec/util_jid_spec.lua @ 13949:863dd118f8e8 13.0
util.jid: Validate domainparts using IDNA or as IP literals (fixes #1903)
RFC 7622 defines the domainpart as:
> domainpart = IP-literal / IPv4address / ifqdn
Nameprep allows a number of characters that are not legal in DNS
names, such as U+20 " ", colon, slash, brackets, parenthesis.
Notably an IPv6 literal domainpart has the form "[db8::abc:123]", but
the brackets are not valid in IDNA, hence the separate checks for this.
Also see #1967
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 20 Sep 2025 17:46:46 +0200 |
| parents | 249bf1a53866 |
| children | 27e97e5b2c16 |
line wrap: on
line diff
--- a/spec/util_jid_spec.lua Tue Sep 09 00:39:41 2025 +0100 +++ b/spec/util_jid_spec.lua Sat Sep 20 17:46:46 2025 +0200 @@ -64,6 +64,8 @@ test("server/resource", nil, "server", "resource" ); test("server/resource@foo", nil, "server", "resource@foo" ); test("server/resource@foo/bar", nil, "server", "resource@foo/bar"); + test("node@203.0.113.80", "node", "203.0.113.80", nil); + test("node@[2001:db8::50:726f:736f:6479]/foo", "node", "[2001:db8::50:726f:736f:6479]", "foo") -- Always invalid JIDs test(nil, nil, nil, nil); @@ -74,6 +76,9 @@ test("@server/", nil, nil, nil); test("server/", nil, nil, nil); test("/resource", nil, nil, nil); + test("xmpp:test@example.com", nil, nil, nil); + test("xmpp:example.com", nil, nil, nil); + test("+123@bridge.example.com)", nil, nil, nil); end); it("should reject invalid arguments", function () assert.has_error(function () jid.prepped_split(false) end)
