From de7b3503a47ea7d5a6177359f6c799c2dd5e586e Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Tue, 28 Jan 2014 03:26:18 +0100 Subject: Jidprep also handles the resource part --- src/xmpp/jid.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/xmpp') diff --git a/src/xmpp/jid.cpp b/src/xmpp/jid.cpp index 4f9917b..e3b0c8f 100644 --- a/src/xmpp/jid.cpp +++ b/src/xmpp/jid.cpp @@ -59,7 +59,22 @@ std::string jidprep(const std::string& original) return ""; } - return std::string(local) + "@" + domain; + // If there is no resource, stop here + if (jid.resource.empty()) + return std::string(local) + "@" + domain; + + // Otherwise, also process the resource part + char resource[max_jid_part_len] = {}; + memcpy(resource, jid.resource.data(), jid.resource.size()); + rc = static_cast(::stringprep(resource, max_jid_part_len, + static_cast(0), stringprep_xmpp_resourceprep)); + if (rc != STRINGPREP_OK) + { + log_error(error_msg + stringprep_strerror(rc)); + return ""; + } + return std::string(local) + "@" + domain + "/" + resource; + #else (void)original; return ""; -- cgit v1.2.3