Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix auth basic encoding (no auth system)
Followup #42410

Fixes #42405
  • Loading branch information
elpaso committed Mar 25, 2021
1 parent 1a7fe6a commit 1ba3c26
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/qgsdatasourceuri.cpp
Expand Up @@ -635,7 +635,7 @@ void QgsDataSourceUri::setEncodedUri( const QByteArray &uri )
mAuthConfigId.clear();

QUrl url;
url.setQuery( QString::fromLatin1( uri ) );
url.setQuery( QString::fromUtf8( uri ) );
const QUrlQuery query( url );

const auto constQueryItems = query.queryItems( QUrl::ComponentFormattingOption::FullyDecoded );
Expand All @@ -654,7 +654,7 @@ void QgsDataSourceUri::setEncodedUri( const QByteArray &uri )

void QgsDataSourceUri::setEncodedUri( const QString &uri )
{
setEncodedUri( uri.toLatin1() );
setEncodedUri( uri.toUtf8() );
}

QString QgsDataSourceUri::quotedTablename() const
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 1ba3c26

Please sign in to comment.