diff --git a/src/lib/autofill/autofill.cpp b/src/lib/autofill/autofill.cpp index 767b6e431..a53a0aa31 100644 --- a/src/lib/autofill/autofill.cpp +++ b/src/lib/autofill/autofill.cpp @@ -254,8 +254,10 @@ void AutoFill::updateEntry(const PageFormData &formData, const AutoFillData &upd mApp->dbWriter()->executeQuery(query); } +// If password was filled in the page, returns all saved passwords on this page QList AutoFill::completePage(WebPage* page) { + bool completed = false; QList list; if (!page) { @@ -273,7 +275,11 @@ QList AutoFill::completePage(WebPage* page) const AutoFillData data = getFirstFormData(pageUrl); PageFormCompleter completer(page); - completer.completePage(data.postData); + completed = completer.completePage(data.postData); + } + + if (!completed) { + list.clear(); } return list; diff --git a/src/lib/autofill/pageformcompleter.cpp b/src/lib/autofill/pageformcompleter.cpp index 58be19d40..34482d507 100644 --- a/src/lib/autofill/pageformcompleter.cpp +++ b/src/lib/autofill/pageformcompleter.cpp @@ -90,8 +90,10 @@ PageFormData PageFormCompleter::extractFormData(const QByteArray &postData) cons return formData; } -void PageFormCompleter::completePage(const QByteArray &data) const +// Returns if any data was actually filled in page +bool PageFormCompleter::completePage(const QByteArray &data) const { + bool completed = false; const QueryItems &queryItems = createQueryItems(data); // Input types that are being completed @@ -105,11 +107,6 @@ void PageFormCompleter::completePage(const QByteArray &data) const const QString &key = queryItems.at(i).first; const QString &value = queryItems.at(i).second; - /* Is it really necessary? - key = QUrl::fromEncoded(key.toUtf8()).toString(); - value = QUrl::fromEncoded(value.toUtf8()).toString(); - */ - for (int i = 0; i < inputs.count(); i++) { QWebElement element = inputs.at(i); const QString &typeAttr = element.attribute("type"); @@ -119,10 +116,13 @@ void PageFormCompleter::completePage(const QByteArray &data) const } if (key == element.attribute("name")) { + completed = true; element.setAttribute("value", value); } } } + + return completed; } bool PageFormCompleter::queryItemsContains(const QueryItems &queryItems, const QString &attributeName, diff --git a/src/lib/autofill/pageformcompleter.h b/src/lib/autofill/pageformcompleter.h index 921f0ce6d..44393d5dd 100644 --- a/src/lib/autofill/pageformcompleter.h +++ b/src/lib/autofill/pageformcompleter.h @@ -41,7 +41,7 @@ public: explicit PageFormCompleter(QWebPage* page); PageFormData extractFormData(const QByteArray &postData) const; - void completePage(const QByteArray &data) const; + bool completePage(const QByteArray &data) const; private: typedef QPair QueryItem;