mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 15:15:50 +08:00
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:
committed by
Roland Winklmeier
parent
2cc88d9c6a
commit
03c642d88a
@@ -109,12 +109,18 @@ namespace BlackCore
|
||||
|
||||
if (nwReply->error() == QNetworkReply::NoError)
|
||||
{
|
||||
QString json(nwReply->readAll());
|
||||
const QString json(nwReply->readAll().trimmed());
|
||||
if (json.isEmpty())
|
||||
{
|
||||
CLogMessage(this).error("Authentication failed, no response from %1") << urlString;
|
||||
return;
|
||||
}
|
||||
if (!json.startsWith('{') || !json.endsWith('}'))
|
||||
{
|
||||
CLogMessage(this).error("Illegal JSON object: %1") << CNetworkUtils::removeHtmlPartsFromPhpErrorMessage(json);
|
||||
return;
|
||||
}
|
||||
|
||||
QJsonObject jsonObj(Json::jsonObjectFromString(json));
|
||||
CAuthenticatedUser user(CAuthenticatedUser::fromDatabaseJson(jsonObj));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user