Skip to content

Commit

Permalink
Add test for server + encoding
Browse files Browse the repository at this point in the history
(cherry picked from commit 0498ddd)
  • Loading branch information
elpaso authored and nyalldawson committed Feb 19, 2021
1 parent 69e3990 commit 8829430
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion tests/src/python/test_qgsserver_wms_getmap.py
Expand Up @@ -32,7 +32,7 @@

from test_qgsserver import QgsServerTestBase
from utilities import unitTestDataPath
from qgis.core import QgsProject
from qgis.core import QgsProject, QgsVectorLayer

# Strip path and content length because path may vary
RE_STRIP_UNCHECKABLE = br'MAP=[^"]+|Content-Length: \d+'
Expand Down Expand Up @@ -1812,6 +1812,47 @@ def test_multiple_layers_with_equal_name(self):
r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetMap_DuplicateNames")

def test_wms_getmap_plus_sign(self):
"""Test issue GH #41116"""

vl = QgsVectorLayer('Point?crs=epsg:4326&field=int:integer', 'test+plus', 'memory')
p = QgsProject()
p.addMapLayers([vl])
qs = "?" + "&".join(["%s=%s" % i for i in list({
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetMap",
"LAYERS": urllib.parse.quote('test+plus'),
"STYLES": "",
"FORMAT": "image/png",
"BBOX": "-170,-80,170,80",
"HEIGHT": "500",
"WIDTH": "500",
"CRS": "EPSG:4326"
}.items())])

r, h = self._result(self._execute_request_project(qs, p))
# No exceptions
self.assertEqual(h['Content-Type'], 'image/png')
self.assertFalse(b"The layer 'test plus' does not exist" in r)

# + literal: we get an exception
qs = "?" + "&".join(["%s=%s" % i for i in list({
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetMap",
"LAYERS": 'test+plus',
"STYLES": "",
"FORMAT": "image/png",
"BBOX": "-170,-80,170,80",
"HEIGHT": "500",
"WIDTH": "500",
"CRS": "EPSG:4326"
}.items())])

r, h = self._result(self._execute_request_project(qs, p))
self.assertTrue(b"The layer 'test plus' does not exist" in r)


if __name__ == '__main__':
unittest.main()

0 comments on commit 8829430

Please sign in to comment.