From bcb0f845924a34a36b2cd797ef1b696556cef98e Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 26 May 2019 23:32:59 +0200 Subject: [PATCH] Do not ASSERT in booking reader if format is NOT compatibel See https://discordapp.com/channels/539048679160676382/568904623151382546/582299692352929793 --- src/blackcore/vatsim/vatsimbookingreader.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/blackcore/vatsim/vatsimbookingreader.cpp b/src/blackcore/vatsim/vatsimbookingreader.cpp index 0897d02b6..9f8dd1204 100644 --- a/src/blackcore/vatsim/vatsimbookingreader.cpp +++ b/src/blackcore/vatsim/vatsimbookingreader.cpp @@ -16,6 +16,7 @@ #include "blackmisc/network/url.h" #include "blackmisc/network/user.h" #include "blackmisc/statusmessage.h" +#include "blackmisc/verify.h" #include #include @@ -99,15 +100,30 @@ namespace BlackCore const QString xmlData = nwReply->readAll(); nwReply->close(); // close asap + if (xmlData.isEmpty() || !xmlData.contains("", Qt::CaseInsensitive)) + { + CLogMessage(this).warning(u"Reading bookings wrong XML format for '%1'") << nwReply->url().toString(); + m_failures++; + emit this->dataRead(CEntityFlags::BookingEntity, CEntityFlags::ReadFailed, 0); + return; + } + QDomDocument doc; QDateTime updateTimestamp = QDateTime::currentDateTimeUtc(); // default if (doc.setContent(xmlData)) { const QDomNode timestamp = doc.elementsByTagName("timestamp").at(0); const QString ts = timestamp.toElement().text().trimmed(); - Q_ASSERT(!ts.isEmpty()); + BLACK_AUDIT_X(!ts.isEmpty(), Q_FUNC_INFO, "Wrong timestamp format"); - if (!ts.isEmpty()) + if (ts.isEmpty()) + { + CLogMessage(this).warning(u"Reading bookings wrong XML timestamp format for '%1'") << nwReply->url().toString(); + m_failures++; + emit this->dataRead(CEntityFlags::BookingEntity, CEntityFlags::ReadFailed, 0); + return; + } + else { // normally the timestamp is always updated from backend // if this changes in the future we're prepared