mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
Using clever approach to find username inputs in form.
Saving passwords and usernames should now work for much more sites. It now looks for input[type="email"] and inputs without type attribute too. Closes #674
This commit is contained in:
parent
30719365ac
commit
1fef4efec7
|
@ -12,6 +12,7 @@ Version 1.4.0
|
||||||
* option to disable alt/ctrl + numbers shortcuts
|
* option to disable alt/ctrl + numbers shortcuts
|
||||||
* option to switch to tab from locationbar popup completer
|
* option to switch to tab from locationbar popup completer
|
||||||
* use .qupzilla/tmp instead of /tmp for temporary data
|
* use .qupzilla/tmp instead of /tmp for temporary data
|
||||||
|
* saving passwords should now work for much more sites
|
||||||
* fixed loading NYTimes skimmer page
|
* fixed loading NYTimes skimmer page
|
||||||
* fixed cookie domain handling according to RFC 6265
|
* fixed cookie domain handling according to RFC 6265
|
||||||
* fixed qvalue format in Accept-Language HTTP header
|
* fixed qvalue format in Accept-Language HTTP header
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* QupZilla - WebKit based browser
|
||||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -248,10 +248,10 @@ void AutoFillModel::completePage(WebPage* page)
|
||||||
|
|
||||||
for (int i = 0; i < inputs.count(); i++) {
|
for (int i = 0; i < inputs.count(); i++) {
|
||||||
QWebElement element = inputs.at(i);
|
QWebElement element = inputs.at(i);
|
||||||
|
const QString &typeAttr = element.attribute("type");
|
||||||
|
|
||||||
if (element.attribute("type") != QLatin1String("text")
|
if (typeAttr != QLatin1String("text") && typeAttr != QLatin1String("password")
|
||||||
&& element.attribute("type") != QLatin1String("password")
|
&& typeAttr != QLatin1String("email") && !typeAttr.isEmpty()) {
|
||||||
&& !element.attribute("type").isEmpty()) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ void AutoFillModel::completePage(WebPage* page)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#include <QDebug>
|
||||||
void AutoFillModel::post(const QNetworkRequest &request, const QByteArray &outgoingData)
|
void AutoFillModel::post(const QNetworkRequest &request, const QByteArray &outgoingData)
|
||||||
{
|
{
|
||||||
// Don't save in private browsing
|
// Don't save in private browsing
|
||||||
|
@ -334,11 +334,26 @@ void AutoFillModel::post(const QNetworkRequest &request, const QByteArray &outgo
|
||||||
// We need to find username, we suppose that username is first not empty input[type=text] in form
|
// We need to find username, we suppose that username is first not empty input[type=text] in form
|
||||||
// Tell me better solution. Maybe first try to find name="user", name="username" ?
|
// Tell me better solution. Maybe first try to find name="user", name="username" ?
|
||||||
|
|
||||||
foreach(const QWebElement & element, foundForm.findAll("input[type=\"text\"]")) {
|
bool found = false;
|
||||||
|
QStringList selectors;
|
||||||
|
selectors << "input[type=\"text\"][name*=\"user\"]"
|
||||||
|
<< "input[type=\"text\"][name*=\"name\"]"
|
||||||
|
<< "input[type=\"text\"]"
|
||||||
|
<< "input[type=\"email\"]"
|
||||||
|
<< "input:not([type=\"hidden\"])";
|
||||||
|
|
||||||
|
foreach(const QString & selector, selectors) {
|
||||||
|
foreach(const QWebElement & element, foundForm.findAll(selector)) {
|
||||||
usernameName = element.attribute("name");
|
usernameName = element.attribute("name");
|
||||||
usernameValue = getValueFromData(data, element);
|
usernameValue = getValueFromData(data, element);
|
||||||
|
|
||||||
if (!usernameName.isEmpty() && !usernameValue.isEmpty()) {
|
if (!usernameName.isEmpty() && !usernameValue.isEmpty()) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* QupZilla - WebKit based browser
|
||||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -32,9 +32,21 @@ AutoFillNotification::AutoFillNotification(const QUrl &url, const QByteArray &da
|
||||||
{
|
{
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
ui->setupUi(widget());
|
ui->setupUi(widget());
|
||||||
ui->label->setText(tr("Do you want QupZilla to remember the password for <b>%1</b> on %2?").arg(user, url.host()));
|
|
||||||
ui->closeButton->setIcon(qIconProvider->standardIcon(QStyle::SP_DialogCloseButton));
|
ui->closeButton->setIcon(qIconProvider->standardIcon(QStyle::SP_DialogCloseButton));
|
||||||
|
|
||||||
|
QString hostPart;
|
||||||
|
QString userPart;
|
||||||
|
|
||||||
|
if (!url.host().isEmpty()) {
|
||||||
|
hostPart = tr("on %1").arg(url.host());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!user.isEmpty()) {
|
||||||
|
userPart = tr("for <b>%1</b>").arg(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->label->setText(tr("Do you want QupZilla to remember the password %1 %2?").arg(userPart, hostPart));
|
||||||
|
|
||||||
connect(ui->remember, SIGNAL(clicked()), this, SLOT(remember()));
|
connect(ui->remember, SIGNAL(clicked()), this, SLOT(remember()));
|
||||||
connect(ui->never, SIGNAL(clicked()), this, SLOT(never()));
|
connect(ui->never, SIGNAL(clicked()), this, SLOT(never()));
|
||||||
connect(ui->notnow, SIGNAL(clicked()), this, SLOT(hide()));
|
connect(ui->notnow, SIGNAL(clicked()), this, SLOT(hide()));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user