From 597fe50d3728c77158a5c64ecffb37c836bf9e44 Mon Sep 17 00:00:00 2001 From: Elise Date: Tue, 19 Mar 2019 13:28:11 -0400 Subject: [PATCH 1/2] GH-2551 Trim server name and IP strings --- application/pages/instance/ServersPage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/pages/instance/ServersPage.cpp b/application/pages/instance/ServersPage.cpp index 35f167aad..8db4d1094 100644 --- a/application/pages/instance/ServersPage.cpp +++ b/application/pages/instance/ServersPage.cpp @@ -37,10 +37,10 @@ struct Server Server(nbt::tag_compound& server) { std::string addressStr(server["ip"]); - m_address = QString::fromUtf8(addressStr.c_str()); + m_address = QString::fromUtf8(addressStr.c_str()).trimmed(); std::string nameStr(server["name"]); - m_name = QString::fromUtf8(nameStr.c_str()); + m_name = QString::fromUtf8(nameStr.c_str()).trimmed(); if(server["icon"]) { From 1fc199697cb72f927bde9390a6308276c1cd1fdb Mon Sep 17 00:00:00 2001 From: Elise Date: Fri, 29 Mar 2019 11:25:37 -0400 Subject: [PATCH 2/2] GH-2551 Trim at serialization --- application/pages/instance/ServersPage.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/application/pages/instance/ServersPage.cpp b/application/pages/instance/ServersPage.cpp index 8db4d1094..eb4757acc 100644 --- a/application/pages/instance/ServersPage.cpp +++ b/application/pages/instance/ServersPage.cpp @@ -37,10 +37,10 @@ struct Server Server(nbt::tag_compound& server) { std::string addressStr(server["ip"]); - m_address = QString::fromUtf8(addressStr.c_str()).trimmed(); + m_address = QString::fromUtf8(addressStr.c_str()); std::string nameStr(server["name"]); - m_name = QString::fromUtf8(nameStr.c_str()).trimmed(); + m_name = QString::fromUtf8(nameStr.c_str()); if(server["icon"]) { @@ -64,8 +64,8 @@ struct Server void serialize(nbt::tag_compound& server) { - server.insert("name", m_name.toUtf8().toStdString()); - server.insert("ip", m_address.toUtf8().toStdString()); + server.insert("name", m_name.trimmed().toUtf8().toStdString()); + server.insert("ip", m_address.trimmed().toUtf8().toStdString()); if(m_icon.size()) { server.insert("icon", m_icon.toBase64().toStdString());