From 972af5552d61f2e58ba168c25079e8a6473d7582 Mon Sep 17 00:00:00 2001 From: nowrep Date: Tue, 21 May 2013 16:42:12 +0200 Subject: [PATCH] [GnomeKeyring] Make tests pass with gnome-keyring backend. Fixed PasswordManager::urlEncodePassword - ~ is also needed to encode --- src/lib/autofill/passwordmanager.cpp | 3 ++- .../GnomeKeyringPasswords/gnomekeyringpasswordbackend.cpp | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/autofill/passwordmanager.cpp b/src/lib/autofill/passwordmanager.cpp index 1f8fbe0f4..b06ddaeea 100644 --- a/src/lib/autofill/passwordmanager.cpp +++ b/src/lib/autofill/passwordmanager.cpp @@ -174,7 +174,8 @@ QByteArray PasswordManager::urlEncodePassword(const QString &password) { // Exclude space to properly decode to + QByteArray encodedPass = QUrl::toPercentEncoding(password, " "); - encodedPass.replace(' ', '+'); + encodedPass.replace(' ', '+'); // space has to be encoded to + + encodedPass.replace('~', "%7E"); // ~ is unreserved char, needs to be manually encoded return encodedPass; } diff --git a/src/plugins/GnomeKeyringPasswords/gnomekeyringpasswordbackend.cpp b/src/plugins/GnomeKeyringPasswords/gnomekeyringpasswordbackend.cpp index cb4bafd4a..62fbc5c81 100644 --- a/src/plugins/GnomeKeyringPasswords/gnomekeyringpasswordbackend.cpp +++ b/src/plugins/GnomeKeyringPasswords/gnomekeyringpasswordbackend.cpp @@ -29,16 +29,16 @@ static PasswordEntry createEntry(GnomeKeyringFound* item) { PasswordEntry entry; entry.id = item->item_id; - entry.password = item->secret; + entry.password = QString::fromUtf8(item->secret); for (unsigned i = 0; i < item->attributes->len; ++i) { GnomeKeyringAttribute attr = g_array_index(item->attributes, GnomeKeyringAttribute, i); if (strcmp(attr.name, "host") == 0) { - entry.host = attr.value.string; + entry.host = QString::fromUtf8(attr.value.string); } else if (strcmp(attr.name, "username") == 0) { - entry.username = attr.value.string; + entry.username = QString::fromUtf8(attr.value.string); } else if (strcmp(attr.name, "data") == 0) { entry.data = attr.value.string;