Skip to content
Snippets Groups Projects
Commit ae1e063d authored by Guillaume Roguez's avatar Guillaume Roguez Committed by gerrit2
Browse files

ring_account: force UTF8 validation for IncomingAccountMessage

Invalid UTF-8 string cause D-BUS exception if given as string object.
This patch fixes that by forcing validation of incoming IM from
DHT. This validation strip-out invalid byte sequence.

Change-Id: I1d599664d767df7a3796f5afd93afc61178baaae
Tuleap: #239
parent efbd779d
No related branches found
No related tags found
No related merge requests found
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "account_schema.h" #include "account_schema.h"
#include "logger.h" #include "logger.h"
#include "manager.h" #include "manager.h"
#include "utf8_utils.h"
#ifdef RING_VIDEO #ifdef RING_VIDEO
#include "libav_utils.h" #include "libav_utils.h"
...@@ -66,6 +67,7 @@ ...@@ -66,6 +67,7 @@
#include <sstream> #include <sstream>
#include <cctype> #include <cctype>
#include <cstdarg> #include <cstdarg>
#include <string>
namespace ring { namespace ring {
...@@ -894,10 +896,9 @@ RingAccount::doRegister_() ...@@ -894,10 +896,9 @@ RingAccount::doRegister_()
return true; return true;
auto from = v.from.toString(); auto from = v.from.toString();
std::map<std::string, std::string> msg = {{"text/plain", v.msg}}; std::map<std::string, std::string> payloads = {{"text/plain",
RING_DBG("Text message received from DHT from %s, %zu part(s)", utf8_make_valid(v.msg)}};
from.c_str(), msg.size()); shared->onTextMessage(from, payloads);
emitSignal<DRing::ConfigurationSignal::IncomingAccountMessage>(this_.getAccountID(), from, msg);
return true; return true;
} }
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment