1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

[PasswordManager] Fixed encoding passwords to url encoded format.

This commit is contained in:
nowrep 2013-05-20 13:33:13 +02:00
parent 8da362b119
commit 5c698d5d2a
4 changed files with 13 additions and 11 deletions

View File

@ -170,6 +170,14 @@ QString PasswordManager::createHost(const QUrl &url)
return host;
}
QByteArray PasswordManager::urlEncodePassword(const QString &password)
{
// Exclude space to properly decode to +
QByteArray encodedPass = QUrl::toPercentEncoding(password, " ");
encodedPass.replace(' ', '+');
return encodedPass;
}
void PasswordManager::ensureLoaded()
{
if (!m_loaded) {

View File

@ -80,6 +80,7 @@ public:
void unregisterBackend(PasswordBackend* backend);
static QString createHost(const QUrl &url);
static QByteArray urlEncodePassword(const QString &password);
private:
void ensureLoaded();

View File

@ -230,8 +230,8 @@ void AutoFillManager::editPass()
QString text = QInputDialog::getText(this, tr("Edit password"), tr("Change password:"), QLineEdit::Normal, entry.password, &ok);
if (ok && !text.isEmpty()) {
QByteArray oldPass = "=" + QUrl::toPercentEncoding(entry.password);
entry.data.replace(oldPass, "=" + QUrl::toPercentEncoding(text.toUtf8()));
QByteArray oldPass = "=" + PasswordManager::urlEncodePassword(entry.password);
entry.data.replace(oldPass, "=" + PasswordManager::urlEncodePassword(text));
entry.password = text;
QVariant v;

View File

@ -25,13 +25,6 @@ extern "C" {
#include "gnome-keyring.h"
}
static QByteArray urlEncodePassword(const QString &password)
{
QByteArray encodedPass = QUrl::toPercentEncoding(password);
encodedPass.replace(' ', '+');
return encodedPass;
}
static PasswordEntry createEntry(GnomeKeyringFound* item)
{
PasswordEntry entry;
@ -55,7 +48,7 @@ static PasswordEntry createEntry(GnomeKeyringFound* item)
}
}
entry.data.replace(QByteArray("___PASSWORD-VALUE___"), urlEncodePassword(entry.password));
entry.data.replace(QByteArray("___PASSWORD-VALUE___"), PasswordManager::urlEncodePassword(entry.password));
return entry;
}
@ -70,7 +63,7 @@ static GnomeKeyringAttributeList* createAttributes(const PasswordEntry &entry)
gnome_keyring_attribute_list_append_string(attributes, "username", value.constData());
value = entry.data;
value.replace(urlEncodePassword(entry.password), "___PASSWORD-VALUE___");
value.replace(PasswordManager::urlEncodePassword(entry.password), "___PASSWORD-VALUE___");
gnome_keyring_attribute_list_append_string(attributes, "data", value.constData());
value = entry.host.toUtf8();