Skip to content
Permalink
Browse files
Fix auth basic encoding (no auth system)
Followup #42410

Fixes #42405

(cherry picked from commit 1ba3c26)
  • Loading branch information
elpaso authored and nyalldawson committed Apr 17, 2021
1 parent ec5476c commit 4a12a4514c5ec6d0017b5d7877066a7c152829e5
Showing with 15 additions and 2 deletions.
  1. +2 −2 src/core/qgsdatasourceuri.cpp
  2. +13 −0 tests/src/core/testqgsdatasourceuri.cpp
@@ -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 );
@@ -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
@@ -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 4a12a45

Please sign in to comment.