Skip to content
Permalink
Browse files

Merge pull request #6879 from arnaud-morvan/server_fix_url_params_dec…

…oding

[server] Avoid %2B to be interpreted as space in querystring
  • Loading branch information
rldhont committed May 2, 2018
2 parents 73ad80f + 4087521 commit 9e5f38208e5777997ea25f3b21376dbe85288737
Showing with 8 additions and 5 deletions.
  1. +3 −5 src/server/qgsserverrequest.cpp
  2. +5 −0 tests/src/python/test_qgsserver_request.py
@@ -76,14 +76,12 @@ QMap<QString, QString> QgsServerRequest::parameters() const
typedef QPair<QString, QString> pair_t;

QUrlQuery query( mUrl );
query.setQuery( query.query().replace( '+', QStringLiteral( "%20" ) ) );

QList<pair_t> items = query.queryItems( QUrl::FullyDecoded );
Q_FOREACH ( const pair_t &pair, items )
{
// prepare the value
QString value = pair.second;
value.replace( '+', ' ' );

mParams.insert( pair.first.toUpper(), value );
mParams.insert( pair.first.toUpper(), pair.second );
}
mDecoded = true;
}
@@ -48,6 +48,11 @@ def test_requestParameters(self):
for k, v in request.headers().items():
self.assertEqual(parameters[k], v)

def test_requestParametersDecoding(self):
"""Test request parameters decoding"""
request = QgsServerRequest('http://somesite.com/somepath?parm1=val1%20%2B+val2', QgsServerRequest.GetMethod)
self.assertEqual(request.parameters()['PARM1'], 'val1 + val2')

def test_requestUrl(self):
"""Test url"""
request = QgsServerRequest('http://somesite.com/somepath', QgsServerRequest.GetMethod)

0 comments on commit 9e5f382

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