Skip to content

Commit 8a09a19

Browse files
authoredOct 3, 2017
Merge pull request #5150 from pblottiere/server_bugfix_ogc_getfeatureinfo_invalid_format
[server][bugfix] Fix OGC test getfeatureinfo:invalid-info_format
2 parents 58f64bb + 04cdf49 commit 8a09a19

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed
 

‎src/server/services/wms/qgswmsparameters.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,8 +1179,12 @@ namespace QgsWms
11791179
f = Format::XML;
11801180
else if ( fStr.startsWith( QLatin1String( "text/html" ), Qt::CaseInsensitive ) )
11811181
f = Format::HTML;
1182+
else if ( fStr.startsWith( QLatin1String( "text/plain" ), Qt::CaseInsensitive ) )
1183+
f = Format::TEXT;
11821184
else if ( fStr.startsWith( QLatin1String( "application/vnd.ogc.gml" ), Qt::CaseInsensitive ) )
11831185
f = Format::GML;
1186+
else
1187+
f = Format::NONE;
11841188

11851189
return f;
11861190
}

‎src/server/services/wms/qgswmsrenderer.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,13 @@ namespace QgsWms
998998
QByteArray ba;
999999

10001000
QgsWmsParameters::Format infoFormat = mWmsParameters.infoFormat();
1001-
if ( infoFormat == QgsWmsParameters::Format::TEXT )
1001+
1002+
if ( infoFormat == QgsWmsParameters::Format::NONE )
1003+
{
1004+
throw QgsBadRequestException( QStringLiteral( "InvalidFormat" ),
1005+
QStringLiteral( "Invalid INFO_FORMAT parameter" ) );
1006+
}
1007+
else if ( infoFormat == QgsWmsParameters::Format::TEXT )
10021008
ba = convertFeatureInfoToText( result );
10031009
else if ( infoFormat == QgsWmsParameters::Format::HTML )
10041010
ba = convertFeatureInfoToHtml( result );

‎tests/src/python/test_qgsserver_wms.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ def test_project_wms(self):
8888
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320',
8989
'wms_getfeatureinfo-text-html')
9090

91+
# Test getfeatureinfo response text
92+
self.wms_request_compare('GetFeatureInfo',
93+
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
94+
'transparent=true&' +
95+
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
96+
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
97+
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&' +
98+
'info_format=text/plain',
99+
'wms_getfeatureinfo-text-plain')
100+
91101
# Test getfeatureinfo default info_format
92102
self.wms_request_compare('GetFeatureInfo',
93103
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
@@ -97,6 +107,16 @@ def test_project_wms(self):
97107
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320',
98108
'wms_getfeatureinfo-text-plain')
99109

110+
# Test getfeatureinfo invalid info_format
111+
self.wms_request_compare('GetFeatureInfo',
112+
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
113+
'transparent=true&' +
114+
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
115+
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
116+
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320&' +
117+
'info_format=InvalidFormat',
118+
'wms_getfeatureinfo-invalid-format')
119+
100120
# Regression for #8656
101121
# Mind the gap! (the space in the FILTER expression)
102122
self.wms_request_compare('GetFeatureInfo',
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*****
2+
Content-Type: text/xml; charset=utf-8
3+
4+
<ServiceExceptionReport version="1.3.0" xmlns="http://www.opengis.net/ogc">
5+
<ServiceException code="InvalidFormat">Invalid INFO_FORMAT parameter</ServiceException>
6+
</ServiceExceptionReport>

0 commit comments

Comments
 (0)
Please sign in to comment.