Anonymization: don't log when it is disabled.

Also fix unexpected concatenation error in Poco::URI::encode generating
eg. authorid=localhost0 xauthorid=localhost0localhost0 in the output.

Change-Id: I560e47e31884eeb1c662f468436ed7541cfb082d
This commit is contained in:
Michael Meeks 2019-03-15 10:51:19 +01:00
parent d8bb92cdcf
commit 5627c767ab
2 changed files with 8 additions and 2 deletions

View file

@ -658,7 +658,9 @@ namespace Util
if (plain.empty() || anonymized.empty())
return;
LOG_TRC("Anonymizing [" << plain << "] -> [" << anonymized << "].");
auto &log = Log::logger();
if (log.trace() && plain != anonymized)
LOG_TRC("Anonymizing [" << plain << "] -> [" << anonymized << "].");
std::unique_lock<std::mutex> lock(AnonymizedMutex);
@ -673,7 +675,9 @@ namespace Util
const auto it = AnonymizedStrings.find(text);
if (it != AnonymizedStrings.end())
{
LOG_TRC("Found anonymized [" << text << "] -> [" << it->second << "].");
auto &log = Log::logger();
if (log.trace() && text != it->second)
LOG_TRC("Found anonymized [" << text << "] -> [" << it->second << "].");
return it->second;
}
}

View file

@ -419,12 +419,14 @@ bool ClientSession::loadDocument(const char* /*buffer*/, int /*length*/,
std::string encodedUserId;
Poco::URI::encode(getUserId(), "", encodedUserId);
oss << " authorid=" << encodedUserId;
encodedUserId = "";
Poco::URI::encode(LOOLWSD::anonymizeUsername(getUserId()), "", encodedUserId);
oss << " xauthorid=" << encodedUserId;
std::string encodedUserName;
Poco::URI::encode(getUserName(), "", encodedUserName);
oss << " author=" << encodedUserName;
encodedUserName = "";
Poco::URI::encode(LOOLWSD::anonymizeUsername(getUserName()), "", encodedUserName);
oss << " xauthor=" << encodedUserName;
}