Skip to content
Permalink
Browse files

Merge pull request #42472 from elpaso/bugfix-gh42405-wrong-password-e…

…ncoding-with-auth-basic-followup

Fix auth basic encoding (no auth system)
  • Loading branch information
elpaso committed Mar 25, 2021
2 parents 877b2ff + b2f2955 commit 4c06804a967b3e15358784e18a7b0b7413cf50e2
Showing with 14 additions and 1 deletion.
  1. +1 −1 src/providers/wms/qgswmscapabilities.h
  2. +13 −0 tests/src/core/testqgsdatasourceuri.cpp
@@ -670,7 +670,7 @@ struct QgsWmsAuthorization
}
else if ( !mUserName.isEmpty() || !mPassword.isEmpty() )
{
request.setRawHeader( "Authorization", "Basic " + QStringLiteral( "%1:%2" ).arg( mUserName, mPassword ).toLatin1().toBase64() );
request.setRawHeader( "Authorization", "Basic " + QStringLiteral( "%1:%2" ).arg( mUserName, mPassword ).toUtf8().toBase64() );
}

if ( !mReferer.isEmpty() )
@@ -299,6 +299,19 @@ void TestQgsDataSourceUri::checkAuthParams()
QCOMPARE( uri4.param( QStringLiteral( "password" ) ), QStringLiteral( "pa%%word" ) );
QCOMPARE( uri4.password(), QStringLiteral( "pa%%word" ) );

// issue GH #42405
uri4.setEncodedUri( QStringLiteral( "dpiMode=7&url=http://localhost:8000/ows/?MAP%3D/home/bug.qgs&username=username&password=qgis%C3%A8%C3%A9" ) );
QCOMPARE( uri4.param( QStringLiteral( "username" ) ), QStringLiteral( "username" ) );
QCOMPARE( uri4.username(), QStringLiteral( "username" ) );
QCOMPARE( uri4.param( QStringLiteral( "password" ) ), QStringLiteral( "qgisèé" ) );
QCOMPARE( uri4.password(), QStringLiteral( "qgisèé" ) );

uri4.setEncodedUri( QStringLiteral( "dpiMode=7&url=http://localhost:8000/&username=username&password=%1" ).arg( QString( QUrl::toPercentEncoding( QStringLiteral( "😁😂😍" ) ) ) ) );
QCOMPARE( uri4.param( QStringLiteral( "username" ) ), QStringLiteral( "username" ) );
QCOMPARE( uri4.username(), QStringLiteral( "username" ) );
QCOMPARE( uri4.param( QStringLiteral( "password" ) ), QStringLiteral( "😁😂😍" ) );
QCOMPARE( uri4.password(), QStringLiteral( "😁😂😍" ) );

}


0 comments on commit 4c06804

Please sign in to comment.