From e5d87ed052d537d259c8e4b250394f5fdb8fe88b Mon Sep 17 00:00:00 2001 From: Qv2ray Bot <59914293+Qv2ray-Bot@users.noreply.github.com> Date: Sat, 18 Jan 2020 10:54:55 +0800 Subject: [PATCH] fix: fixed #257 prevent using manual function Stringify --- Build.Counter | 2 +- src/QvCoreConfigOperations_Convertion.cpp | 4 +-- src/components/QvKernelInteractions.cpp | 4 +-- src/main.cpp | 2 +- src/ui/w_MainWindow_extra.cpp | 10 ++++---- src/ui/w_RoutesEditor.cpp | 20 +++++++-------- src/utils/QvHelpers.cpp | 30 ----------------------- src/utils/QvHelpers.hpp | 4 +-- 8 files changed, 23 insertions(+), 53 deletions(-) diff --git a/Build.Counter b/Build.Counter index f7374e5e..8afc5d50 100644 --- a/Build.Counter +++ b/Build.Counter @@ -1 +1 @@ -2866 +2871 diff --git a/src/QvCoreConfigOperations_Convertion.cpp b/src/QvCoreConfigOperations_Convertion.cpp index 76775f54..20d72a9d 100644 --- a/src/QvCoreConfigOperations_Convertion.cpp +++ b/src/QvCoreConfigOperations_Convertion.cpp @@ -37,7 +37,7 @@ namespace Qv2ray vmessUriRoot["host"] = realHost; vmessUriRoot["path"] = transfer.wsSettings.path; } else if (transfer.network == "h2" || transfer.network == "http") { - vmessUriRoot["host"] = Stringify(transfer.httpSettings.host, ","); + vmessUriRoot["host"] = transfer.httpSettings.host.join(","); vmessUriRoot["path"] = transfer.httpSettings.path; } @@ -206,7 +206,7 @@ namespace Qv2ray } else{\ *errMessage = QObject::tr(#key " does not exist."); \ LOG(MODULE_IMPORT, "Cannot process \"" #key "\" since it's not included in the json object." ) \ - LOG(MODULE_IMPORT, " --> values: " + Stringify(val) ) \ + LOG(MODULE_IMPORT, " --> values: " + val.join(";")) \ LOG(MODULE_IMPORT, " --> PS: " + ps) \ }\ } diff --git a/src/components/QvKernelInteractions.cpp b/src/components/QvKernelInteractions.cpp index ec552b71..3203878e 100644 --- a/src/components/QvKernelInteractions.cpp +++ b/src/components/QvKernelInteractions.cpp @@ -77,7 +77,7 @@ namespace Qv2ray } QString output = QString(proc.readAllStandardOutput()); - LOG(MODULE_VCORE, "V2ray output: " + Stringify(SplitLines(output))) + LOG(MODULE_VCORE, "V2ray output: " + SplitLines(output).join(";")) *message = SplitLines(output).first(); return true; } @@ -144,7 +144,7 @@ namespace Qv2ray inboundTags.append(tag); } - DEBUG(MODULE_VCORE, "Found Inbound Tags: " + Stringify(inboundTags)) + DEBUG(MODULE_VCORE, "Found Inbound Tags: " + inboundTags.join(";")) QString json = JsonToString(root); // Write the final configuration to the disk. StringToFile(&json, new QFile(QV2RAY_GENERATED_FILE_PATH)); diff --git a/src/main.cpp b/src/main.cpp index bcd5ca3f..f5c0b386 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -164,7 +164,7 @@ bool initialiseQv2ray() // Even the last folder failed to pass the check. LOG(MODULE_INIT, "FATAL") LOG(MODULE_INIT, " ---> CANNOT find a proper place to store Qv2ray config files.") - QString searchPath = Stringify(configFilePaths, NEWLINE); + QString searchPath = configFilePaths.join(NEWLINE); QvMessageBoxWarn(nullptr, QObject::tr("Cannot Start Qv2ray"), QObject::tr("Cannot find a place to store config files.") + NEWLINE + QObject::tr("Qv2ray has searched these paths below:") + diff --git a/src/ui/w_MainWindow_extra.cpp b/src/ui/w_MainWindow_extra.cpp index e9d41a85..4900287e 100644 --- a/src/ui/w_MainWindow_extra.cpp +++ b/src/ui/w_MainWindow_extra.cpp @@ -49,8 +49,8 @@ void MainWindow::MWFindAndStartAutoConfig() on_startButton_clicked(); } else { QvMessageBoxWarn(this, tr("Autostarting a config"), tr("Could not find a specified config named: ") + NEWLINE + - name + NEWLINE + NEWLINE + - tr("Please reset the settings in Preference Window")); + name + NEWLINE + NEWLINE + + tr("Please reset the settings in Preference Window")); } } else if (connectionListWidget->topLevelItemCount() > 0) { // Make the first one our default selected item. @@ -98,7 +98,7 @@ void MainWindow::MWSetSystemProxy() LOG(MODULE_PROXY, " --> PAC is configured to use socks but socks is not enabled.") LOG(MODULE_PROXY, " --> PAC is configuted to use http but http is not enabled.") QvMessageBoxWarn(this, tr("PAC Processing Failed"), tr("HTTP or SOCKS inbound is not properly configured for PAC") + - NEWLINE + tr("Qv2ray will continue, but will not set system proxy.")); + NEWLINE + tr("Qv2ray will continue, but will not set system proxy.")); canSetSystemProxy = false; } } else { @@ -240,8 +240,8 @@ void MainWindow::CheckSubscriptionsUpdate() if (!updateList.isEmpty()) { QvMessageBoxWarn(this, tr("Update Subscriptions"), - tr("There are subscriptions need to be updated, please go to subscriptions window to update them.") + NEWLINE + NEWLINE + - tr("These subscriptions are out-of-date: ") + NEWLINE + Stringify(updateList)); + tr("There are subscriptions need to be updated, please go to subscriptions window to update them.") + NEWLINE + NEWLINE + + tr("These subscriptions are out-of-date: ") + NEWLINE + updateList.join(";")); on_subsButton_clicked(); } } diff --git a/src/ui/w_RoutesEditor.cpp b/src/ui/w_RoutesEditor.cpp index 73b5d407..99e4bdbd 100644 --- a/src/ui/w_RoutesEditor.cpp +++ b/src/ui/w_RoutesEditor.cpp @@ -373,19 +373,19 @@ void RouteEditor::ShowCurrentRuleDetail() routePortTxt->setText(CurrentRule.port); // // Users - QString users = Stringify(CurrentRule.user, NEWLINE); + QString users = CurrentRule.user.join(NEWLINE); routeUserTxt->setPlainText(users); // // Incoming Sources - QString sources = Stringify(CurrentRule.source, NEWLINE); + QString sources = CurrentRule.source.join(NEWLINE); sourceIPList->setPlainText(sources); // // Domains - QString domains = Stringify(CurrentRule.domain, NEWLINE); + QString domains = CurrentRule.domain.join(NEWLINE); hostList->setPlainText(domains); // // Outcoming IPs - QString ips = Stringify(CurrentRule.ip, NEWLINE); + QString ips = CurrentRule.ip.join(NEWLINE); ipList->setPlainText(ips); LOAD_FLAG_END } @@ -410,7 +410,7 @@ void RouteEditor::on_routeProtocolHTTPCB_stateChanged(int arg1) if (routeProtocolBTCB->isChecked()) protocols.push_back("bittorrent"); CurrentRule.protocol = protocols; - statusLabel->setText(tr("Protocol list changed: ") + Stringify(protocols)); + statusLabel->setText(tr("Protocol list changed: ") + protocols.join(";")); } void RouteEditor::on_routeProtocolTLSCB_stateChanged(int arg1) { @@ -424,7 +424,7 @@ void RouteEditor::on_routeProtocolTLSCB_stateChanged(int arg1) if (routeProtocolBTCB->isChecked()) protocols.push_back("bittorrent"); CurrentRule.protocol = protocols; - statusLabel->setText(tr("Protocol list changed: ") + Stringify(protocols)); + statusLabel->setText(tr("Protocol list changed: ") + protocols.join(";")); } void RouteEditor::on_routeProtocolBTCB_stateChanged(int arg1) { @@ -438,7 +438,7 @@ void RouteEditor::on_routeProtocolBTCB_stateChanged(int arg1) if (routeProtocolTLSCB->isChecked()) protocols.push_back("tls"); CurrentRule.protocol = protocols; - statusLabel->setText(tr("Protocol list changed: ") + Stringify(protocols)); + statusLabel->setText(tr("Protocol list changed: ") + protocols.join(";")); } void RouteEditor::on_balancerAddBtn_clicked() { @@ -693,7 +693,7 @@ void RouteEditor::on_editBtn_clicked() if (protocol != "http" && protocol != "mtproto" && protocol != "socks" && protocol != "dokodemo-door") { QvMessageBoxWarn(this, tr("Cannot Edit"), tr("Currently, this type of outbound is not supported by the editor.") + "\r\n" + - tr("We will launch Json Editor instead.")); + tr("We will launch Json Editor instead.")); statusLabel->setText(tr("Opening JSON editor")); JsonEditor *w = new JsonEditor(_in, this); _result = INBOUND(w->OpenEditor()); @@ -727,8 +727,8 @@ void RouteEditor::on_editBtn_clicked() if (protocol != "vmess" && protocol != "shadowsocks" && protocol != "socks") { QvMessageBoxWarn(this, tr("Unsupported Outbound Type"), - tr("This outbound entry is not supported by the GUI editor.") + NEWLINE + - tr("We will launch Json Editor instead.")); + tr("This outbound entry is not supported by the GUI editor.") + NEWLINE + + tr("We will launch Json Editor instead.")); JsonEditor w(_out, this); statusLabel->setText(tr("Opening JSON editor")); _result = OUTBOUND(w.OpenEditor()); diff --git a/src/utils/QvHelpers.cpp b/src/utils/QvHelpers.cpp index 92f3ed45..48a4d0cd 100644 --- a/src/utils/QvHelpers.cpp +++ b/src/utils/QvHelpers.cpp @@ -47,36 +47,6 @@ namespace Qv2ray return randomString; } - QString Stringify(list list, QString saperator) - { - QString out; - - for (auto item : list) { - out.append(QString::fromStdString(item)); - out.append(saperator); - } - - if (out.length() >= 1) - out = out.remove(out.length() - 1, 1); - - return out; - } - - QString Stringify(QList list, QString saperator) - { - QString out; - - for (auto item : list) { - out.append(item); - out.append(saperator); - } - - if (out.length() >= 1) - out = out.remove(out.length() - 1, 1); - - return out; - } - QString StringFromFile(QFile *source) { source->open(QFile::ReadOnly); diff --git a/src/utils/QvHelpers.hpp b/src/utils/QvHelpers.hpp index ca1108e1..af1bdb3d 100644 --- a/src/utils/QvHelpers.hpp +++ b/src/utils/QvHelpers.hpp @@ -30,8 +30,8 @@ namespace Qv2ray QString JsonToString(QJsonObject json, QJsonDocument::JsonFormat format = QJsonDocument::JsonFormat::Indented); QString JsonToString(QJsonArray array, QJsonDocument::JsonFormat format = QJsonDocument::JsonFormat::Indented); QString VerifyJsonString(const QString &source); - QString Stringify(list list, QString saperator = ";"); - QString Stringify(QList list, QString saperator = ";"); + //QString Stringify(list list, QString saperator = ";"); + //QString Stringify(QList list, QString saperator = ";"); QString FormatBytes(long long bytes); void DeducePossibleFileName(const QString &baseDir, QString *fileName, const QString &extension); QString ConvertGFWToPAC(const QString &rawContent, const QString &customProxyString);