GH-1164 make sure the censor filter never contains empty keys
This commit is contained in:
parent
d7b3887fe1
commit
4e3af265da
@ -170,21 +170,7 @@ std::shared_ptr<LaunchTask> LegacyInstance::createLaunchTask(AuthSessionPtr sess
|
||||
}
|
||||
if (session)
|
||||
{
|
||||
QMap<QString, QString> filter;
|
||||
if (session->session != "-")
|
||||
filter[session->session] = tr("<SESSION ID>");
|
||||
filter[session->access_token] = tr("<ACCESS TOKEN>");
|
||||
filter[session->client_token] = tr("<CLIENT TOKEN>");
|
||||
filter[session->uuid] = tr("<PROFILE ID>");
|
||||
filter[session->player_name] = tr("<PROFILE NAME>");
|
||||
|
||||
auto i = session->u.properties.begin();
|
||||
while (i != session->u.properties.end())
|
||||
{
|
||||
filter[i.value()] = "<" + i.key().toUpper() + ">";
|
||||
++i;
|
||||
}
|
||||
process->setCensorFilter(filter);
|
||||
process->setCensorFilter(createCensorFilterFromSession(session));
|
||||
}
|
||||
return process;
|
||||
}
|
||||
|
@ -204,6 +204,39 @@ QProcessEnvironment MinecraftInstance::createEnvironment()
|
||||
return env;
|
||||
}
|
||||
|
||||
QMap<QString, QString> MinecraftInstance::createCensorFilterFromSession(AuthSessionPtr session)
|
||||
{
|
||||
if(!session)
|
||||
{
|
||||
return QMap<QString, QString>();
|
||||
}
|
||||
auto & sessionRef = *session.get();
|
||||
QMap<QString, QString> filter;
|
||||
auto addToFilter = [&filter](QString key, QString value)
|
||||
{
|
||||
if(key.trimmed().size())
|
||||
{
|
||||
filter[key] = value;
|
||||
}
|
||||
};
|
||||
if (sessionRef.session != "-")
|
||||
{
|
||||
addToFilter(sessionRef.session, tr("<SESSION ID>"));
|
||||
}
|
||||
addToFilter(sessionRef.access_token, tr("<ACCESS TOKEN>"));
|
||||
addToFilter(sessionRef.client_token, tr("<CLIENT TOKEN>"));
|
||||
addToFilter(sessionRef.uuid, tr("<PROFILE ID>"));
|
||||
addToFilter(sessionRef.player_name, tr("<PROFILE NAME>"));
|
||||
|
||||
auto i = sessionRef.u.properties.begin();
|
||||
while (i != sessionRef.u.properties.end())
|
||||
{
|
||||
addToFilter(i.value(), "<" + i.key().toUpper() + ">");
|
||||
++i;
|
||||
}
|
||||
return filter;
|
||||
}
|
||||
|
||||
MessageLevel::Enum MinecraftInstance::guessLevel(const QString &line, MessageLevel::Enum level)
|
||||
{
|
||||
QRegularExpression re("\\[(?<timestamp>[0-9:]+)\\] \\[[^/]+/(?<level>[^\\]]+)\\]");
|
||||
|
@ -43,6 +43,9 @@ public:
|
||||
|
||||
/// guess log level from a line of minecraft log
|
||||
virtual MessageLevel::Enum guessLevel(const QString &line, MessageLevel::Enum level);
|
||||
|
||||
protected:
|
||||
QMap<QString, QString> createCensorFilterFromSession(AuthSessionPtr session);
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<MinecraftInstance> MinecraftInstancePtr;
|
||||
|
@ -277,21 +277,7 @@ std::shared_ptr<LaunchTask> OneSixInstance::createLaunchTask(AuthSessionPtr sess
|
||||
}
|
||||
if (session)
|
||||
{
|
||||
QMap<QString, QString> filter;
|
||||
if (session->session != "-")
|
||||
filter[session->session] = tr("<SESSION ID>");
|
||||
filter[session->access_token] = tr("<ACCESS TOKEN>");
|
||||
filter[session->client_token] = tr("<CLIENT TOKEN>");
|
||||
filter[session->uuid] = tr("<PROFILE ID>");
|
||||
filter[session->player_name] = tr("<PROFILE NAME>");
|
||||
|
||||
auto i = session->u.properties.begin();
|
||||
while (i != session->u.properties.end())
|
||||
{
|
||||
filter[i.value()] = "<" + i.key().toUpper() + ">";
|
||||
++i;
|
||||
}
|
||||
process->setCensorFilter(filter);
|
||||
process->setCensorFilter(createCensorFilterFromSession(session));
|
||||
}
|
||||
return process;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user