diff options
author | Florent Le Coz <louiz@louiz.org> | 2014-01-28 03:26:18 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2014-01-28 03:30:12 +0100 |
commit | de7b3503a47ea7d5a6177359f6c799c2dd5e586e (patch) | |
tree | 69d435bed55074a4d0269c126d3f7c9bcc7593c5 /src/xmpp | |
parent | b71547a32b9beefbe24465a5ba092d2f9b3b04e5 (diff) | |
download | biboumi-de7b3503a47ea7d5a6177359f6c799c2dd5e586e.tar.gz biboumi-de7b3503a47ea7d5a6177359f6c799c2dd5e586e.tar.bz2 biboumi-de7b3503a47ea7d5a6177359f6c799c2dd5e586e.tar.xz biboumi-de7b3503a47ea7d5a6177359f6c799c2dd5e586e.zip |
Jidprep also handles the resource part
Diffstat (limited to 'src/xmpp')
-rw-r--r-- | src/xmpp/jid.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
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_rc>(::stringprep(resource, max_jid_part_len, + static_cast<Stringprep_profile_flags>(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 ""; |