Skip to content
Permalink
Browse files

[WFS provider] Be robust to field names ending with spaces in Describ…

…eFeatureType

Fixes #3426
  • Loading branch information
rouault committed Oct 6, 2016
1 parent 4169360 commit fb50a3e3698df5b3fd9a6537bb50700e00d219d3
Showing with 9 additions and 1 deletion.
  1. +7 −0 src/providers/wfs/qgswfsprovider.cpp
  2. +2 −1 tests/src/python/test_provider_wfs.py
@@ -1246,8 +1246,15 @@ bool QgsWFSProvider::readAttributesFromSchema( QDomDocument& schemaDoc,
for ( int i = 0; i < attributeNodeList.size(); ++i )
{
QDomElement attributeElement = attributeNodeList.at( i ).toElement();

//attribute name
QString name = attributeElement.attribute( "name" );
// Some servers like http://ogi.state.ok.us/geoserver/wfs on layer ogi:doq_centroids
// return attribute names padded with spaces. See http://hub.qgis.org/issues/3426
// I'm not completely sure how legal this
// is but this validates with Xerces 3.1, and its schema analyzer does also the trimming.
name = name.trimmed();

//attribute type
QString type = attributeElement.attribute( "type" );
if ( type.isEmpty() )
@@ -111,7 +111,8 @@ def setUpClass(cls):
<xsd:complexContent>
<xsd:extension base="gml:AbstractFeatureType">
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="0" name="pk" nillable="true" type="xsd:long"/>
<!-- add a trailing space to the name to test http://hub.qgis.org/issues/3426 -->
<xsd:element maxOccurs="1" minOccurs="0" name="pk " nillable="true" type="xsd:long"/>
<xsd:element maxOccurs="1" minOccurs="0" name="cnt" nillable="true" type="xsd:long"/>
<xsd:element maxOccurs="1" minOccurs="0" name="name" nillable="true" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="0" name="name2" nillable="true" type="xsd:string"/>

0 comments on commit fb50a3e

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