Skip to content

Commit 05b8bf7

Browse files
authoredDec 18, 2017
Merge pull request #5876 from peppsac/fix_17694
Fix parameter name decoding when using POST + urlencoded
2 parents 00dbc73 + adb7af9 commit 05b8bf7

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed
 

‎src/server/qgsrequesthandler.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,12 @@ void QgsRequestHandler::parseInput()
228228
typedef QPair<QString, QString> pair_t;
229229
QUrlQuery query( inputString );
230230
QList<pair_t> items = query.queryItems();
231-
Q_FOREACH ( const pair_t &pair, items )
231+
Q_FOREACH ( pair_t pair, items )
232232
{
233-
const QString value = QUrl::fromPercentEncoding( pair.second.toUtf8() );
234-
mRequest.setParameter( pair.first.toUpper(), value );
233+
// QUrl::fromPercentEncoding doesn't replace '+' with space
234+
const QString key = QUrl::fromPercentEncoding( pair.first.replace( '+', ' ' ).toUtf8() );
235+
const QString value = QUrl::fromPercentEncoding( pair.second.replace( '+', ' ' ).toUtf8() );
236+
mRequest.setParameter( key.toUpper(), value );
235237
}
236238
setupParameters();
237239
}

‎tests/src/python/test_qgsserver_wms_getprint.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
from test_qgsserver import QgsServerTestBase
3535
from qgis.core import QgsProject
36+
from qgis.server import QgsServerRequest
3637

3738
# Strip path and content length because path may vary
3839
RE_STRIP_UNCHECKABLE = b'MAP=[^"]+|Content-Length: \d+'
@@ -302,7 +303,7 @@ def test_wms_getprint_opacity(self):
302303
"REQUEST": "GetPrint",
303304
"TEMPLATE": "layoutA4",
304305
"FORMAT": "png",
305-
"map0:EXTENT": "-33626185.498,-13032965.185,33978427.737,16020257.031",
306+
"map0%3AEXTENT": "-33626185.498,-13032965.185,33978427.737,16020257.031",
306307
"map0:LAYERS": "Country,Hello",
307308
"CRS": "EPSG:3857",
308309
"SELECTION": "Country: 4",
@@ -313,22 +314,23 @@ def test_wms_getprint_opacity(self):
313314
r, h = self._result(self._execute_request(qs))
314315
self._img_diff_error(r, h, "WMS_GetPrint_Opacity")
315316

316-
qs = "?" + "&".join(["%s=%s" % i for i in list({
317+
def test_wms_getprint_opacity_post(self):
318+
qs = "&".join(["%s=%s" % i for i in list({
317319
"MAP": urllib.parse.quote(self.projectPath),
318320
"SERVICE": "WMS",
319321
"VERSION": "1.1.1",
320322
"REQUEST": "GetPrint",
321323
"TEMPLATE": "layoutA4",
322324
"FORMAT": "png",
323-
"map0:EXTENT": "-33626185.498,-13032965.185,33978427.737,16020257.031",
325+
"map0%3AEXTENT": "-33626185.498,-13032965.185,33978427.737,16020257.031",
324326
"map0:LAYERS": "Country,Hello",
325327
"CRS": "EPSG:3857",
326328
"SELECTION": "Country: 4",
327329
"LAYERS": "Country,Hello",
328330
"OPACITIES": "125%2C125"
329331
}.items())])
330332

331-
r, h = self._result(self._execute_request(qs))
333+
r, h = self._result(self._execute_request('', QgsServerRequest.PostMethod, data=qs.encode('utf-8')))
332334
self._img_diff_error(r, h, "WMS_GetPrint_Opacity")
333335

334336
def test_wms_getprint_highlight(self):

0 commit comments

Comments
 (0)
Please sign in to comment.