diff --git a/CHANGELOG b/CHANGELOG index 4bcd06250..9f72c6573 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ Version 1.4.0 * option to disable alt/ctrl + numbers shortcuts * option to switch to tab from locationbar popup completer * use .qupzilla/tmp instead of /tmp for temporary data + * saving passwords should now work for much more sites * fixed loading NYTimes skimmer page * fixed cookie domain handling according to RFC 6265 * fixed qvalue format in Accept-Language HTTP header diff --git a/src/lib/autofill/autofillmodel.cpp b/src/lib/autofill/autofillmodel.cpp index 16fa71820..fc29e4faf 100644 --- a/src/lib/autofill/autofillmodel.cpp +++ b/src/lib/autofill/autofillmodel.cpp @@ -1,6 +1,6 @@ /* ============================================================ * QupZilla - WebKit based browser -* Copyright (C) 2010-2012 David Rosca +* Copyright (C) 2010-2013 David Rosca * * 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 @@ -248,10 +248,10 @@ void AutoFillModel::completePage(WebPage* page) for (int i = 0; i < inputs.count(); i++) { QWebElement element = inputs.at(i); + const QString &typeAttr = element.attribute("type"); - if (element.attribute("type") != QLatin1String("text") - && element.attribute("type") != QLatin1String("password") - && !element.attribute("type").isEmpty()) { + if (typeAttr != QLatin1String("text") && typeAttr != QLatin1String("password") + && typeAttr != QLatin1String("email") && !typeAttr.isEmpty()) { continue; } @@ -261,7 +261,7 @@ void AutoFillModel::completePage(WebPage* page) } } } - +#include void AutoFillModel::post(const QNetworkRequest &request, const QByteArray &outgoingData) { // 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 // Tell me better solution. Maybe first try to find name="user", name="username" ? - foreach(const QWebElement & element, foundForm.findAll("input[type=\"text\"]")) { - usernameName = element.attribute("name"); - usernameValue = getValueFromData(data, element); + 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\"])"; - if (!usernameName.isEmpty() && !usernameValue.isEmpty()) { + foreach(const QString & selector, selectors) { + foreach(const QWebElement & element, foundForm.findAll(selector)) { + usernameName = element.attribute("name"); + usernameValue = getValueFromData(data, element); + + if (!usernameName.isEmpty() && !usernameValue.isEmpty()) { + found = true; + break; + } + } + + if (found) { break; } } diff --git a/src/lib/autofill/autofillnotification.cpp b/src/lib/autofill/autofillnotification.cpp index c4db2d168..e7efcd517 100644 --- a/src/lib/autofill/autofillnotification.cpp +++ b/src/lib/autofill/autofillnotification.cpp @@ -1,6 +1,6 @@ /* ============================================================ * QupZilla - WebKit based browser -* Copyright (C) 2010-2012 David Rosca +* Copyright (C) 2010-2013 David Rosca * * 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 @@ -32,9 +32,21 @@ AutoFillNotification::AutoFillNotification(const QUrl &url, const QByteArray &da { setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(widget()); - ui->label->setText(tr("Do you want QupZilla to remember the password for %1 on %2?").arg(user, url.host())); 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 %1").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->never, SIGNAL(clicked()), this, SLOT(never())); connect(ui->notnow, SIGNAL(clicked()), this, SLOT(hide()));