Skip to content

Commit fb50a3e

Browse files
committed
[WFS provider] Be robust to field names ending with spaces in DescribeFeatureType
Fixes #3426
1 parent 4169360 commit fb50a3e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/providers/wfs/qgswfsprovider.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -1246,8 +1246,15 @@ bool QgsWFSProvider::readAttributesFromSchema( QDomDocument& schemaDoc,
12461246
for ( int i = 0; i < attributeNodeList.size(); ++i )
12471247
{
12481248
QDomElement attributeElement = attributeNodeList.at( i ).toElement();
1249+
12491250
//attribute name
12501251
QString name = attributeElement.attribute( "name" );
1252+
// Some servers like http://ogi.state.ok.us/geoserver/wfs on layer ogi:doq_centroids
1253+
// return attribute names padded with spaces. See http://hub.qgis.org/issues/3426
1254+
// I'm not completely sure how legal this
1255+
// is but this validates with Xerces 3.1, and its schema analyzer does also the trimming.
1256+
name = name.trimmed();
1257+
12511258
//attribute type
12521259
QString type = attributeElement.attribute( "type" );
12531260
if ( type.isEmpty() )

tests/src/python/test_provider_wfs.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ def setUpClass(cls):
111111
<xsd:complexContent>
112112
<xsd:extension base="gml:AbstractFeatureType">
113113
<xsd:sequence>
114-
<xsd:element maxOccurs="1" minOccurs="0" name="pk" nillable="true" type="xsd:long"/>
114+
<!-- add a trailing space to the name to test http://hub.qgis.org/issues/3426 -->
115+
<xsd:element maxOccurs="1" minOccurs="0" name="pk " nillable="true" type="xsd:long"/>
115116
<xsd:element maxOccurs="1" minOccurs="0" name="cnt" nillable="true" type="xsd:long"/>
116117
<xsd:element maxOccurs="1" minOccurs="0" name="name" nillable="true" type="xsd:string"/>
117118
<xsd:element maxOccurs="1" minOccurs="0" name="name2" nillable="true" type="xsd:string"/>

0 commit comments

Comments
 (0)