Skip to content

Commit

Permalink
Replace colon in typenames
Browse files Browse the repository at this point in the history
Fixes #41292 QGISserver WFS returns invalid GML in case of cascading WFS

(cherry picked from commit 65b272d)
  • Loading branch information
elpaso authored and nyalldawson committed Mar 19, 2021
1 parent 03d8ed3 commit 8cb8164
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/server/services/wfs/qgswfsgetfeature.cpp
Expand Up @@ -201,7 +201,7 @@ namespace QgsWfs
getFeatureQuery &query = *qIt;
QString typeName = query.typeName;

if ( !mapLayerMap.keys().contains( typeName ) )
if ( !mapLayerMap.contains( typeName ) )
{
throw QgsRequestNotWellFormedException( QStringLiteral( "TypeName '%1' unknown" ).arg( typeName ) );
}
Expand Down Expand Up @@ -333,7 +333,7 @@ namespace QgsWfs
accessControl->filterFeatures( vlayer, featureRequest );

QStringList attributes = QStringList();
for ( int idx : attrIndexes )
for ( int idx : qgis::as_const( attrIndexes ) )
{
attributes.append( vlayer->fields().field( idx ).name() );
}
Expand Down
7 changes: 4 additions & 3 deletions src/server/services/wfs/qgswfsutils.cpp
Expand Up @@ -56,7 +56,8 @@ namespace QgsWfs
href = request.originalUrl();
QUrlQuery q( href );

for ( auto param : q.queryItems() )
const auto constQueryItems = q.queryItems();
for ( const auto &param : constQueryItems )
{
if ( sFilter.contains( param.first.toUpper() ) )
q.removeAllQueryItems( param.first );
Expand All @@ -73,14 +74,14 @@ namespace QgsWfs
QString name = layer->name();
if ( !layer->shortName().isEmpty() )
name = layer->shortName();
name = name.replace( ' ', '_' );
name = name.replace( ' ', '_' ).replace( ':', '-' );
return name;
}

QgsVectorLayer *layerByTypeName( const QgsProject *project, const QString &typeName )
{
QStringList layerIds = QgsServerProjectUtils::wfsLayerIds( *project );
for ( const QString &layerId : layerIds )
for ( const QString &layerId : qgis::as_const( layerIds ) )
{
QgsMapLayer *layer = project->mapLayer( layerId );
if ( !layer )
Expand Down

0 comments on commit 8cb8164

Please sign in to comment.