Navigation Menu

Skip to content

Commit

Permalink
Fixes segfault when filter is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere authored and nyalldawson committed Sep 9, 2018
1 parent 04f8ee8 commit fbdacc0
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -2799,7 +2799,11 @@ namespace QgsWms
}
QDomElement filterElem = filterXml.firstChildElement();
std::unique_ptr<QgsExpression> expression( QgsOgcUtils::expressionFromOgcFilter( filterElem, filteredLayer ) );
mFeatureFilter.setFilter( filteredLayer, *expression );

if ( expression )
{
mFeatureFilter.setFilter( filteredLayer, *expression );
}
}
else
{
Expand Down
43 changes: 43 additions & 0 deletions tests/src/python/test_qgsserver_wms_getmap.py
Expand Up @@ -800,6 +800,49 @@ def test_wms_getmap_filter_ogc(self):
r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetMap_Filter_OGC")

# empty filter
filter = ("(<ogc:Filter xmlns=\"http://www.opengis.net/ogc\">"
"</ogc:Filter>)")
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(self.projectPath),
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetMap",
"LAYERS": "Country,Hello",
"STYLES": "",
"FORMAT": "image/png",
"BBOX": "-16817707,-4710778,5696513,14587125",
"HEIGHT": "500",
"WIDTH": "500",
"CRS": "EPSG:3857",
"FILTER": filter
}.items())])
r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetMap_Filter_OGC2")

# filter on the second layer
filter_hello = ("(<Filter></Filter>)")
filter_country = ("(<Filter><PropertyIsEqualTo><PropertyName>name"
"</PropertyName><Literal>eurasia</Literal>"
"</PropertyIsEqualTo></Filter>)")
filter = "{}{}".format(filter_hello, filter_country)
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(self.projectPath),
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetMap",
"LAYERS": "Hello,Country",
"STYLES": "",
"FORMAT": "image/png",
"BBOX": "-16817707,-4710778,5696513,14587125",
"HEIGHT": "500",
"WIDTH": "500",
"CRS": "EPSG:3857",
"FILTER": filter
}.items())])
r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetMap_Filter_OGC3")

def test_wms_getmap_selection(self):
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(self.projectPath),
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fbdacc0

Please sign in to comment.