mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
[PasswordManager] Fixed encoding passwords to url encoded format.
This commit is contained in:
parent
8da362b119
commit
5c698d5d2a
@ -170,6 +170,14 @@ QString PasswordManager::createHost(const QUrl &url)
|
|||||||
return host;
|
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()
|
void PasswordManager::ensureLoaded()
|
||||||
{
|
{
|
||||||
if (!m_loaded) {
|
if (!m_loaded) {
|
||||||
|
@ -80,6 +80,7 @@ public:
|
|||||||
void unregisterBackend(PasswordBackend* backend);
|
void unregisterBackend(PasswordBackend* backend);
|
||||||
|
|
||||||
static QString createHost(const QUrl &url);
|
static QString createHost(const QUrl &url);
|
||||||
|
static QByteArray urlEncodePassword(const QString &password);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ensureLoaded();
|
void ensureLoaded();
|
||||||
|
@ -230,8 +230,8 @@ void AutoFillManager::editPass()
|
|||||||
QString text = QInputDialog::getText(this, tr("Edit password"), tr("Change password:"), QLineEdit::Normal, entry.password, &ok);
|
QString text = QInputDialog::getText(this, tr("Edit password"), tr("Change password:"), QLineEdit::Normal, entry.password, &ok);
|
||||||
|
|
||||||
if (ok && !text.isEmpty()) {
|
if (ok && !text.isEmpty()) {
|
||||||
QByteArray oldPass = "=" + QUrl::toPercentEncoding(entry.password);
|
QByteArray oldPass = "=" + PasswordManager::urlEncodePassword(entry.password);
|
||||||
entry.data.replace(oldPass, "=" + QUrl::toPercentEncoding(text.toUtf8()));
|
entry.data.replace(oldPass, "=" + PasswordManager::urlEncodePassword(text));
|
||||||
entry.password = text;
|
entry.password = text;
|
||||||
|
|
||||||
QVariant v;
|
QVariant v;
|
||||||
|
@ -25,13 +25,6 @@ extern "C" {
|
|||||||
#include "gnome-keyring.h"
|
#include "gnome-keyring.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
static QByteArray urlEncodePassword(const QString &password)
|
|
||||||
{
|
|
||||||
QByteArray encodedPass = QUrl::toPercentEncoding(password);
|
|
||||||
encodedPass.replace(' ', '+');
|
|
||||||
return encodedPass;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PasswordEntry createEntry(GnomeKeyringFound* item)
|
static PasswordEntry createEntry(GnomeKeyringFound* item)
|
||||||
{
|
{
|
||||||
PasswordEntry entry;
|
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;
|
return entry;
|
||||||
}
|
}
|
||||||
@ -70,7 +63,7 @@ static GnomeKeyringAttributeList* createAttributes(const PasswordEntry &entry)
|
|||||||
gnome_keyring_attribute_list_append_string(attributes, "username", value.constData());
|
gnome_keyring_attribute_list_append_string(attributes, "username", value.constData());
|
||||||
|
|
||||||
value = entry.data;
|
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());
|
gnome_keyring_attribute_list_append_string(attributes, "data", value.constData());
|
||||||
|
|
||||||
value = entry.host.toUtf8();
|
value = entry.host.toUtf8();
|
||||||
|
Loading…
Reference in New Issue
Block a user