Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/wms provider url decoding #59144

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d2ba7d7
make fromPercentEncoding in qgswmsprovider conditional.
cioddi Oct 20, 2024
7e27c6d
ensure values in QgsDataSourceUri are URL-encoded when assigned and p…
cioddi Oct 20, 2024
3db6b6f
fix formatting qgsdatasourceuri.cpp
cioddi Oct 20, 2024
2ddd0d4
fix formatting qgsdatasourceuri.cpp
cioddi Oct 20, 2024
5b17cd6
fix formatting qgsdatasourceuri.cpp
cioddi Oct 20, 2024
93941e1
fix formatting qgsdatasourceuri.cpp
cioddi Oct 20, 2024
cd6fbaa
fix faulty assertion in tests/src/core/testqgsdatasourceuri.cpp
cioddi Oct 20, 2024
a963329
fix faulty assertion of URI parameter values not being fully URL-enco…
cioddi Oct 20, 2024
91d695d
fix formatting qgswmsprovider.cpp
cioddi Oct 20, 2024
f005c57
move QUrl::toPercentEncoding and QUrl::fromPercentEncoding steps from…
cioddi Oct 21, 2024
48b05f7
make sure QgsDataSourceUri values are FullyUrlDecoded when parsing Qg…
cioddi Oct 21, 2024
1473ce8
add decoding step before adding the "url" value to QgsDataSourceUri i…
cioddi Oct 21, 2024
283df37
fix formatting qgswmsprovider.cpp
cioddi Oct 22, 2024
bc7eee5
fix formatting qgswmsprovider.cpp
cioddi Oct 22, 2024
574642f
adjust tests to QgsDataSourceUri full value URL-encoding
cioddi Oct 27, 2024
66f95b7
fix test tests/src/core/testqgshttpheaders.cpp
cioddi Dec 13, 2024
b66d5a4
fix test tests/src/core/testqgssensorthingsconnection.cpp
cioddi Dec 13, 2024
d380df5
fix test tests/src/core/testqgstiledsceneconnection.cpp
cioddi Dec 13, 2024
d4c8de1
fix test tests/src/core/testqgsvectortileconnection.cpp
cioddi Dec 13, 2024
f2bf3af
fix test tests/src/python/test_qgsvectortile.py
cioddi Dec 13, 2024
91eb342
fix test tests/src/server/wms/test_qgsserver_wms_parameters.cpp
cioddi Dec 13, 2024
adf998d
fix tests tests/src/core/testqgshttpheaders.cpp
cioddi Dec 13, 2024
9d8f89b
Squashed commit of the following:
cioddi Dec 19, 2024
f8e812f
Revert "Squashed commit of the following:"
cioddi Dec 19, 2024
3b7ba63
fix test tests/src/core/testqgshttpheaders.cpp
cioddi Dec 19, 2024
e8a5e6c
fix most tests in tests/src/core/testqgsvectortilelayer.cpp
cioddi Dec 19, 2024
39c6751
fix double URL-encoding issue with curly braces in z,x,y placeholders…
cioddi Jan 3, 2025
2c206b2
Merge branch 'master' into fix/wms-provider-url-decoding
cioddi Jan 3, 2025
e7a7d0a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 3, 2025
8851665
revert QgsHttpheaders change of expected encodedUri value in tests/sr…
cioddi Jan 3, 2025
762ade6
fix TestQgsHttpheaders::createQgsOwsConnection to work with QT 5 and 6
cioddi Jan 4, 2025
744c33f
Revert "fix TestQgsHttpheaders::createQgsOwsConnection to work with Q…
cioddi Jan 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/core/qgsdatasourceuri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ void QgsDataSourceUri::setParam( const QString &key, const QString &value )
else
{
// may be multiple
mParams.insert( key, value );
mParams.insert( key, QUrl::toPercentEncoding( value ) );
cioddi marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -907,7 +907,7 @@ QString QgsDataSourceUri::param( const QString &key ) const
else if ( key == QLatin1String( "authcfg" ) && !mAuthConfigId.isEmpty() )
return mAuthConfigId;

return mParams.value( key );
return QUrl::fromPercentEncoding( mParams.value( key ).toUtf8() );
}

QStringList QgsDataSourceUri::params( const QString &key ) const
Expand Down
5 changes: 4 additions & 1 deletion src/providers/wms/qgswmsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,10 @@ QgsWmsProvider::QgsWmsProvider( QString const &uri, const ProviderOptions &optio
QString QgsWmsProvider::prepareUri( QString uri )
{
// some services provide a percent/url encoded (legend) uri string, always decode here
uri = QUrl::fromPercentEncoding( uri.toUtf8() );
if( uri.startsWith( "https%3A%2F%2F" ) || uri.startsWith( "http%3A%2F%2F" ))
{
uri = QUrl::fromPercentEncoding( uri.toUtf8() );
}

if ( isUrlForWMTS( uri ) )
{
Expand Down
2 changes: 1 addition & 1 deletion tests/src/core/testqgsdatasourceuri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ void TestQgsDataSourceUri::checkAuthParams()
// issue GH #53654
QgsDataSourceUri uri5;
uri5.setEncodedUri( QStringLiteral( "zmax=14&zmin=0&styleUrl=http://localhost:8000/&f=application%2Fvnd.geoserver.mbstyle%2Bjson" ) );
QCOMPARE( uri5.param( QStringLiteral( "f" ) ), QStringLiteral( "application%2Fvnd.geoserver.mbstyle%2Bjson" ) );
QCOMPARE( uri5.param( QStringLiteral( "f" ) ), QStringLiteral( "application/vnd.geoserver.mbstyle+json" ) );

uri5.setEncodedUri( QStringLiteral( "zmax=14&zmin=0&styleUrl=http://localhost:8000/&f=application/vnd.geoserver.mbstyle+json" ) );
QCOMPARE( uri5.param( QStringLiteral( "f" ) ), QStringLiteral( "application/vnd.geoserver.mbstyle+json" ) );
Expand Down
4 changes: 2 additions & 2 deletions tests/src/providers/testqgswmsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@ void TestQgsWmsProvider::absoluteRelativeUri()
QgsProviderMetadata *wmsMetadata = QgsProviderRegistry::instance()->providerMetadata( "wms" );
QVERIFY( wmsMetadata );

QString absoluteUri = "type=mbtiles&url=file://" + QStringLiteral( TEST_DATA_DIR ) + "/isle_of_man.mbtiles";
QString relativeUri = "type=mbtiles&url=file:./isle_of_man.mbtiles";
QString absoluteUri = "type=mbtiles&url=" + QString( QUrl::toPercentEncoding( "file://" + QStringLiteral( TEST_DATA_DIR ) + "/isle_of_man.mbtiles" ) );
QString relativeUri = "type=mbtiles&url=file%3A.%2Fisle_of_man.mbtiles";
QCOMPARE( wmsMetadata->absoluteToRelativeUri( absoluteUri, context ), relativeUri );
QCOMPARE( wmsMetadata->relativeToAbsoluteUri( relativeUri, context ), absoluteUri );
}
Expand Down
Loading