Skip to content

Commit 1ba3c26

Browse files
committedMar 25, 2021
Fix auth basic encoding (no auth system)
Followup #42410 Fixes #42405
1 parent 1a7fe6a commit 1ba3c26

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed
 

‎src/core/qgsdatasourceuri.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ void QgsDataSourceUri::setEncodedUri( const QByteArray &uri )
635635
mAuthConfigId.clear();
636636

637637
QUrl url;
638-
url.setQuery( QString::fromLatin1( uri ) );
638+
url.setQuery( QString::fromUtf8( uri ) );
639639
const QUrlQuery query( url );
640640

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

655655
void QgsDataSourceUri::setEncodedUri( const QString &uri )
656656
{
657-
setEncodedUri( uri.toLatin1() );
657+
setEncodedUri( uri.toUtf8() );
658658
}
659659

660660
QString QgsDataSourceUri::quotedTablename() const

‎tests/src/core/testqgsdatasourceuri.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,19 @@ void TestQgsDataSourceUri::checkAuthParams()
299299
QCOMPARE( uri4.param( QStringLiteral( "password" ) ), QStringLiteral( "pa%%word" ) );
300300
QCOMPARE( uri4.password(), QStringLiteral( "pa%%word" ) );
301301

302+
// issue GH #42405
303+
uri4.setEncodedUri( QStringLiteral( "dpiMode=7&url=http://localhost:8000/ows/?MAP%3D/home/bug.qgs&username=username&password=qgis%C3%A8%C3%A9" ) );
304+
QCOMPARE( uri4.param( QStringLiteral( "username" ) ), QStringLiteral( "username" ) );
305+
QCOMPARE( uri4.username(), QStringLiteral( "username" ) );
306+
QCOMPARE( uri4.param( QStringLiteral( "password" ) ), QStringLiteral( "qgisèé" ) );
307+
QCOMPARE( uri4.password(), QStringLiteral( "qgisèé" ) );
308+
309+
uri4.setEncodedUri( QStringLiteral( "dpiMode=7&url=http://localhost:8000/&username=username&password=%1" ).arg( QString( QUrl::toPercentEncoding( QStringLiteral( "😁😂😍" ) ) ) ) );
310+
QCOMPARE( uri4.param( QStringLiteral( "username" ) ), QStringLiteral( "username" ) );
311+
QCOMPARE( uri4.username(), QStringLiteral( "username" ) );
312+
QCOMPARE( uri4.param( QStringLiteral( "password" ) ), QStringLiteral( "😁😂😍" ) );
313+
QCOMPARE( uri4.password(), QStringLiteral( "😁😂😍" ) );
314+
302315
}
303316

304317

0 commit comments

Comments
 (0)
Please sign in to comment.