Skip to content
Permalink
Browse files
fix percent encoding in wms server parameter
  • Loading branch information
benoitdm-oslandia authored and m-kuhn committed Dec 27, 2021
1 parent 907d0f8 commit a13b29f2ab8867945068d5f1665b704a625f8e98
Showing with 24 additions and 1 deletion.
  1. +2 −1 src/server/qgsserverparameters.cpp
  2. +22 −0 tests/src/server/wms/test_qgsserver_wms_parameters.cpp
@@ -441,7 +441,8 @@ QUrlQuery QgsServerParameters::urlQuery() const

for ( auto param : toMap().toStdMap() )
{
query.addQueryItem( param.first, param.second );
const QString value = QUrl::toPercentEncoding( QString( param.second ) );
query.addQueryItem( param.first, value );
}
}

@@ -29,6 +29,8 @@ class TestQgsServerWmsParameters : public QObject
void cleanupTestCase();

void external_layers();

void percent_encoding();
};

void TestQgsServerWmsParameters::initTestCase()
@@ -75,5 +77,25 @@ void TestQgsServerWmsParameters::external_layers()
QCOMPARE( layers_params[2].mOpacity, 125 );
}

void TestQgsServerWmsParameters::percent_encoding()
{
// '+' in its encoded ('%2B') form is transformed in '+' sign and
// forwarded to parameters subclasses
QUrlQuery query;
query.addQueryItem( "MYPARAM", QString( "a%2Cb%2Cc%2C%C3%A4%C3%B6s+%2B+%25%26%23" ) );

QgsServerParameters params;
params.load( query );
QCOMPARE( params.value( "MYPARAM" ), QString( "a,b,c,äös + %&#" ) );

const QgsWms::QgsWmsParameters wmsParams( params );
QCOMPARE( wmsParams.value( "MYPARAM" ), QString( "a,b,c,äös + %&#" ) );

// back to urlQuery
QgsServerParameters params2;
params2.load( params.urlQuery() );
QCOMPARE( params2.value( "MYPARAM" ), QString( "a,b,c,äös + %&#" ) );
}

QGSTEST_MAIN( TestQgsServerWmsParameters )
#include "test_qgsserver_wms_parameters.moc"

0 comments on commit a13b29f

Please sign in to comment.