Skip to content
Permalink
Browse files

Fix parameter name decoding when using POST + urlencoded

This is a followup of dfe48d1 which solved
the issue for parameter values.

Fixes #17694
  • Loading branch information
peppsac committed Dec 14, 2017
1 parent e9feeaa commit adb7af99335ea8c4b7123e1f2a2708cc30c826ca
Showing with 11 additions and 7 deletions.
  1. +5 −3 src/server/qgsrequesthandler.cpp
  2. +6 −4 tests/src/python/test_qgsserver_wms_getprint.py
@@ -228,10 +228,12 @@ void QgsRequestHandler::parseInput()
typedef QPair<QString, QString> pair_t;
QUrlQuery query( inputString );
QList<pair_t> items = query.queryItems();
Q_FOREACH ( const pair_t &pair, items )
Q_FOREACH ( pair_t pair, items )
{
const QString value = QUrl::fromPercentEncoding( pair.second.toUtf8() );
mRequest.setParameter( pair.first.toUpper(), value );
// QUrl::fromPercentEncoding doesn't replace '+' with space
const QString key = QUrl::fromPercentEncoding( pair.first.replace( '+', ' ' ).toUtf8() );
const QString value = QUrl::fromPercentEncoding( pair.second.replace( '+', ' ' ).toUtf8() );
mRequest.setParameter( key.toUpper(), value );
}
setupParameters();
}
@@ -33,6 +33,7 @@

from test_qgsserver import QgsServerTestBase
from qgis.core import QgsProject
from qgis.server import QgsServerRequest

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

qs = "?" + "&".join(["%s=%s" % i for i in list({
def test_wms_getprint_opacity_post(self):
qs = "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(self.projectPath),
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetPrint",
"TEMPLATE": "layoutA4",
"FORMAT": "png",
"map0:EXTENT": "-33626185.498,-13032965.185,33978427.737,16020257.031",
"map0%3AEXTENT": "-33626185.498,-13032965.185,33978427.737,16020257.031",
"map0:LAYERS": "Country,Hello",
"CRS": "EPSG:3857",
"SELECTION": "Country: 4",
"LAYERS": "Country,Hello",
"OPACITIES": "125%2C125"
}.items())])

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

def test_wms_getprint_highlight(self):

0 comments on commit adb7af9

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