diff --git a/src/providers/wms/qgswmsprovider.cpp b/src/providers/wms/qgswmsprovider.cpp index 407ef083ffee2..0f62d54eb3897 100644 --- a/src/providers/wms/qgswmsprovider.cpp +++ b/src/providers/wms/qgswmsprovider.cpp @@ -600,11 +600,12 @@ bool QgsWmsProvider::setImageCrs( QString const &crs ) void QgsWmsProvider::setQueryItem( QUrlQuery &url, const QString &item, const QString &value ) { - url.removeQueryItem( item ); + QString key = QUrl::toPercentEncoding( item ); + url.removeQueryItem( key ); if ( value.isNull() ) - url.addQueryItem( item, "" ); + url.addQueryItem( key, "" ); else - url.addQueryItem( item, value ); + url.addQueryItem( key, QUrl::toPercentEncoding( value ) ); } void QgsWmsProvider::setFormatQueryItem( QUrlQuery &url ) @@ -1261,8 +1262,8 @@ QUrl QgsWmsProvider::createRequestUrlWMS( const QgsRectangle &viewExtent, int pi { if ( mActiveSubLayerVisibility.constFind( *it ).value() ) { - visibleLayers += QUrl::toPercentEncoding( *it ); - visibleStyles += QUrl::toPercentEncoding( *it2 ); + visibleLayers += *it; + visibleStyles += *it2; } ++it2; diff --git a/tests/src/providers/testqgswmsprovider.cpp b/tests/src/providers/testqgswmsprovider.cpp index b57055c72f8f3..07ba75ead97b3 100644 --- a/tests/src/providers/testqgswmsprovider.cpp +++ b/tests/src/providers/testqgswmsprovider.cpp @@ -100,7 +100,7 @@ class TestQgsWmsProvider: public QgsTest QgsWmsProvider provider( failingAddress, QgsDataProvider::ProviderOptions(), mCapabilities ); QUrl url( provider.createRequestUrlWMS( QgsRectangle( 0, 0, 90, 90 ), 100, 100 ) ); QCOMPARE( url.toString(), QString( "http://localhost:8380/mapserv?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap" - "&BBOX=0,0,90,90&CRS=CRS:84&WIDTH=100&HEIGHT=100&LAYERS=&" + "&BBOX=0%2C0%2C90%2C90&CRS=CRS%3A84&WIDTH=100&HEIGHT=100&LAYERS=&" "STYLES=&FORMAT=&TRANSPARENT=TRUE" ) ); } @@ -116,8 +116,8 @@ class TestQgsWmsProvider: public QgsTest QVERIFY( cap.parseResponse( content, config ) ); QgsWmsProvider provider( failingAddress, QgsDataProvider::ProviderOptions(), &cap ); QUrl url( provider.createRequestUrlWMS( QgsRectangle( 0, 0, 90, 90 ), 100, 100 ) ); - QCOMPARE( url.toString(), QString( "http://localhost:8380/mapserv?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=0,0,90,90&" - "CRS=EPSG:2056&WIDTH=100&HEIGHT=100&" + QCOMPARE( url.toString(), QString( "http://localhost:8380/mapserv?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=0%2C0%2C90%2C90&" + "CRS=EPSG%3A2056&WIDTH=100&HEIGHT=100&" "LAYERS=plus%2Bsign&STYLES=&FORMAT=&TRANSPARENT=TRUE" ) ); }