-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AccountSettings: escape forward- and backslashes in MXIDs
Fixes #842.
- Loading branch information
1 parent
757f3ce
commit f82ebbf
Showing
5 changed files
with
69 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// SPDX-FileCopyrightText: The Quotient Project Contributors | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
#include <QTest> | ||
|
||
#include <Quotient/settings.h> | ||
|
||
class TestSettings : public QObject { | ||
Q_OBJECT | ||
private slots: | ||
void accountSettings(); | ||
}; | ||
|
||
using namespace Qt::Literals; | ||
using Quotient::Settings, Quotient::SettingsGroup, Quotient::AccountSettings; | ||
|
||
void TestSettings::accountSettings() | ||
{ | ||
static const auto AccountsGroupName = u"Accounts"_s; | ||
|
||
QSettings qSettings{}; | ||
qSettings.remove(AccountsGroupName); | ||
const auto mxId = u"@user/with\\slashes:example.org"_s; // Test #842 | ||
const auto escapedMxId = Settings::escapedForSettings(mxId); | ||
AccountSettings(mxId).setHomeserver(QUrl(u"https://example.org"_s)); | ||
qSettings.sync(); | ||
qSettings.beginGroup(AccountsGroupName); | ||
// NB: QSettings::contains() doesn't work on groups, only on leaf keys; hence childGroups below | ||
auto childGroups = qSettings.childGroups(); | ||
QVERIFY(childGroups.contains(escapedMxId)); | ||
QVERIFY(SettingsGroup(AccountsGroupName).childGroups().contains(mxId)); | ||
SettingsGroup(AccountsGroupName).remove(mxId); | ||
qSettings.sync(); | ||
childGroups = qSettings.childGroups(); | ||
QVERIFY(!childGroups.contains(escapedMxId)); | ||
qSettings.endGroup(); | ||
} | ||
|
||
QTEST_GUILESS_MAIN(TestSettings) | ||
#include "testsettings.moc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters