Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 authored and github-actions[bot] committed Mar 25, 2021
1 parent 0398e73 commit 1ca5782
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/providers/wms/qgswmscapabilities.h
Expand Up @@ -764,7 +764,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() )
Expand Down
13 changes: 13 additions & 0 deletions tests/src/core/testqgsdatasourceuri.cpp
Expand Up @@ -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( "😁😂😍" ) );

}


Expand Down

0 comments on commit 1ca5782

Please sign in to comment.