Skip to content
Permalink
Browse files

Better fix for #39243: decode in uri

instead of handling that inside the wms routines.
  • Loading branch information
elpaso committed Oct 13, 2020
1 parent 40997ff commit c8f90c11cae5ccfe62d2ed37f9b242ebab7ff09f
@@ -638,7 +638,7 @@ void QgsDataSourceUri::setEncodedUri( const QByteArray &uri )
url.setQuery( QString::fromLatin1( uri ) );
const QUrlQuery query( url );

const auto constQueryItems = query.queryItems();
const auto constQueryItems = query.queryItems( QUrl::ComponentFormattingOption::FullyDecoded );
for ( const QPair<QString, QString> &item : constQueryItems )
{
if ( item.first == QLatin1String( "username" ) )
@@ -42,9 +42,8 @@ bool QgsWmsSettings::parseUri( const QString &uriString )
uri.setEncodedUri( uriString );

// Setup authentication
QUrlQuery query{ uriString };
mAuth.mUserName = query.queryItemValue( QStringLiteral( "username" ), QUrl::ComponentFormattingOption::FullyDecoded );
mAuth.mPassword = query.queryItemValue( QStringLiteral( "password" ), QUrl::ComponentFormattingOption::FullyDecoded );
mAuth.mUserName = uri.username();
mAuth.mPassword = uri.password();

if ( !uri.authConfigId().isEmpty() )
{
@@ -290,6 +290,15 @@ void TestQgsDataSourceUri::checkAuthParams()
QVERIFY( uri.param( QStringLiteral( "authcfg" ) ).isEmpty() );
QVERIFY( uri.authConfigId().isEmpty() );

// issue GH #39243
QgsDataSourceUri uri4;
uri4.setEncodedUri( QStringLiteral( "dpiMode=7&url=http://localhost:8000/ows/?MAP%3D/home/bug.qgs&username=username&password=pa%25%25word" ) );

QCOMPARE( uri4.param( QStringLiteral( "username" ) ), QStringLiteral( "username" ) );
QCOMPARE( uri4.username(), QStringLiteral( "username" ) );
QCOMPARE( uri4.param( QStringLiteral( "password" ) ), QStringLiteral( "pa%%word" ) );
QCOMPARE( uri4.password(), QStringLiteral( "pa%%word" ) );

}


0 comments on commit c8f90c1

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