Mercurial > prosody-hg
changeset 14106:b5eeb6730721
Merge 13.0->trunk
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 22 Mar 2026 11:28:52 +0100 |
| parents | a124e80d3498 (current diff) 4ed802e45af6 (diff) |
| children | bc33a7269f5a |
| files | plugins/mod_s2s.lua plugins/mod_s2s_auth_dane_in.lua |
| diffstat | 3 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_s2s.lua Wed Mar 11 16:59:10 2026 +0100 +++ b/plugins/mod_s2s.lua Sun Mar 22 11:28:52 2026 +0100 @@ -19,7 +19,7 @@ local stop_timer = require "prosody.util.timer".stop; local st = require "prosody.util.stanza"; local initialize_filters = require "prosody.util.filters".initialize; -local nameprep = require "prosody.util.encodings".stringprep.nameprep; +local prepped_split = require "prosody.util.jid".prepped_split; local new_xmpp_stream = require "prosody.util.xmppstream".new; local s2s_new_incoming = require "prosody.core.s2smanager".new_incoming; local s2s_new_outgoing = require "prosody.core.s2smanager".new_outgoing; @@ -511,8 +511,12 @@ -- Validate to/from local to, from = attr.to, attr.from; - if to then to = nameprep(attr.to); end - if from then from = nameprep(attr.from); end + local function hostprep(s) + local node, host, res = prepped_split(s); + if not (node or res) then return host; end + end + if to then to = hostprep(attr.to); end + if from then from = hostprep(attr.from); end if not to and attr.to then -- COMPAT: Some servers do not reliably set 'to' (especially on stream restarts) session:close({ condition = "improper-addressing", text = "Invalid 'to' address" }); return;
--- a/spec/util_jid_spec.lua Wed Mar 11 16:59:10 2026 +0100 +++ b/spec/util_jid_spec.lua Sun Mar 22 11:28:52 2026 +0100 @@ -79,6 +79,7 @@ test("xmpp:test@example.com", nil, nil, nil); test("xmpp:example.com", nil, nil, nil); test("+123@bridge.example.com)", nil, nil, nil); + test("node@2001:db8::50:726f:736f:6479/foo", nil, nil, nil); end); it("should reject invalid arguments", function () assert.has_error(function () jid.prepped_split(false) end)
--- a/util/jid.lua Wed Mar 11 16:59:10 2026 +0100 +++ b/util/jid.lua Sun Mar 22 11:28:52 2026 +0100 @@ -52,7 +52,8 @@ local function valid_ip(ip) local v6 = match(ip, "^%[([%x:.]+)%]$"); - return net.pton(v6 or ip); + local v4 = match(ip, "^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?$"); + return (v6 or v4) and net.pton(v6 or v4); end local function prepped_split(jid, strict)
