refs #751, detect invalid JSON message

(which normally means a PHP error message in HTML)
* utility function to remove HTML parts
* adjustments
This commit is contained in:
Klaus Basan
2016-08-31 17:13:40 +02:00
committed by Roland Winklmeier
parent 2cc88d9c6a
commit 03c642d88a
4 changed files with 22 additions and 5 deletions

View File

@@ -11,6 +11,7 @@
#include "blackmisc/logcategory.h"
#include "blackmisc/logcategorylist.h"
#include "blackmisc/simulation/aircraftmodellist.h"
#include "blackmisc/network/networkutils.h"
#include "blackmisc/statusmessage.h"
#include "blackmisc/statusmessagelist.h"
#include "blackmisc/stringutils.h"
@@ -24,6 +25,7 @@
using namespace BlackMisc;
using namespace BlackMisc::Simulation;
using namespace BlackMisc::Network;
namespace BlackMisc
{
@@ -97,8 +99,7 @@ namespace BlackMisc
// no object -> most likely some fucked up HTML string with the PHP error
if (!jsonDoc.isObject())
{
QString phpError(jsonResponse);
phpError.remove(QRegExp("<[^>]*>"));
const QString phpError(CNetworkUtils::removeHtmlPartsFromPhpErrorMessage(jsonResponse));
messages.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, phpError));
return false;
}