Skip to content
Permalink
Browse files

[geonode] more robust version string parsing (fix #21093, #21140)

  • Loading branch information
alexbruy authored and nyalldawson committed Feb 8, 2019
1 parent f285d91 commit 440f8d4cbb655942f868dde9ab23b0cc5d69c3b2
Showing with 13 additions and 3 deletions.
  1. +13 −3 src/core/geocms/geonode/qgsgeonoderequest.cpp
@@ -26,6 +26,7 @@
#include <QJsonObject>
#include <QUrl>
#include <QDomDocument>
#include <QRegularExpression>

QgsGeoNodeRequest::QgsGeoNodeRequest( const QString &baseUrl, bool forceRefresh, QObject *parent )
: QObject( parent )
@@ -272,9 +273,18 @@ QList<QgsGeoNodeRequest::ServiceLayerDetail> QgsGeoNodeRequest::parseLayers( con
qint16 minorVersion;
if ( jsonVariantMap.contains( QStringLiteral( "geonode_version" ) ) )
{
const QStringList geonodeVersionSplit = jsonVariantMap.value( QStringLiteral( "geonode_version" ) ).toString().split( '.' );
majorVersion = geonodeVersionSplit.at( 0 ).toInt();
minorVersion = geonodeVersionSplit.at( 1 ).toInt();
QRegularExpression re( "((\\d+)(\\.\\d+))" );
QRegularExpressionMatch match = re.match( jsonVariantMap.value( QStringLiteral( "geonode_version" ) ).toString() );
if ( match.hasMatch() )
{
const QStringList geonodeVersionSplit = match.captured( 0 ).split( '.' );
majorVersion = geonodeVersionSplit.at( 0 ).toInt();
minorVersion = geonodeVersionSplit.at( 1 ).toInt();
}
else
{
return layers;
}
}
else
{

0 comments on commit 440f8d4

Please sign in to comment.
You can’t perform that action at this time.