1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 09:42:10 +02:00

AutoFill manager now properly handles passwords outside mainFrame as

well as special characters in password input name.
Fixed some problems on click2flash when flash content is in iframe and
is multiple times on page (like vimeo videos)
This commit is contained in:
nowrep 2011-05-05 16:27:48 +02:00
parent 1f9d08ea73
commit a01dce6eef
3 changed files with 41 additions and 31 deletions

View File

@ -120,8 +120,15 @@ void AutoFillModel::completePage(WebView* view)
if (!isStored(view->url()))
return;
QWebFrame* frame = view->page()->mainFrame();
QWebElementCollection inputs = frame->findAllElements("input");
QWebElementCollection inputs;
QList<QWebFrame*> frames;
frames.append(view->page()->mainFrame());
while (!frames.isEmpty()) {
QWebFrame* frame = frames.takeFirst();
inputs.append(frame->findAllElements("input"));
frames += frame->childFrames();
}
QSqlQuery query;
query.exec("SELECT data FROM autofill WHERE server='"+view->url().host()+"'");
query.next();
@ -131,10 +138,10 @@ void AutoFillModel::completePage(WebView* view)
QList<QPair<QString, QString> > arguments = QUrl::fromEncoded(QByteArray("http://bla.com/?"+data)).queryItems();
for (int i = 0; i<arguments.count(); i++) {
QString key = arguments.at(i).first;
QString value = arguments.at(i).second;
key.replace("+"," ");
value.replace("+"," ");
QString key = QUrl::fromEncoded(arguments.at(i).first.toAscii()).toString();
QString value = QUrl::fromEncoded(arguments.at(i).second.toAscii()).toString();
//key.replace("+"," ");
//value.replace("+"," ");
for (int i = 0; i<inputs.count(); i++) {
QWebElement element = inputs.at(i);
@ -167,34 +174,34 @@ void AutoFillModel::post(const QNetworkRequest &request, const QByteArray &outgo
if (type!=QWebPage::NavigationTypeFormSubmitted)
return;
QString passwordName="";
QWebFrame* frame = webPage->mainFrame();
QWebElementCollection inputs = frame->findAllElements("input");
for (int i = 0; i<inputs.count(); i++) {
QWebElement element = inputs.at(i);
QString type = element.attribute("type");
QString passwordName = "";
QString passwordValue = "";
if (type == "password")
passwordName = element.attribute("name");
QWebElementCollection inputs;
QList<QWebFrame*> frames;
frames.append(webPage->mainFrame());
while (!frames.isEmpty()) {
QWebFrame* frame = frames.takeFirst();
inputs.append(frame->findAllElements("input[type=\"password\"]"));
frames += frame->childFrames();
}
foreach (QWebElement element, inputs) {
passwordName = element.attribute("name");
passwordValue = element.evaluateJavaScript("this.value").toString();
if (!passwordValue.isEmpty())
break;
}
//Return if storing is not enabled, data for this page is already stored, no password element found in sent data
if (!isStoringEnabled(request.url()) || isStored(request.url()) || passwordName.isEmpty())
if (passwordName.isEmpty() || !isStoringEnabled(request.url()) || isStored(request.url()))
return;
//Return if no password form has been sent
if (!outgoingData.contains((passwordName+"=").toAscii()))
if (!outgoingData.contains((QUrl(passwordName).toEncoded() + "=")) || passwordValue.isEmpty())
return;
QString pass = "";
QList<QPair<QString, QString> > arguments = QUrl::fromEncoded(QByteArray("http://bla.com/?"+outgoingData)).queryItems();
for (int i = 0; i<arguments.count(); i++) {
if (arguments.at(i).first == passwordName) {
pass = arguments.at(i).second;
break;
}
}
AutoFillNotification* aWidget = new AutoFillNotification(request.url(), outgoingData, pass);
AutoFillNotification* aWidget = new AutoFillNotification(request.url(), outgoingData, passwordValue);
webView->addNotification(aWidget);
}

View File

@ -64,7 +64,6 @@ ClickToFlash::ClickToFlash(const QUrl &pluginUrl, const QStringList &argumentNam
QHBoxLayout* horizontalLayout;
QFrame* frame;
QHBoxLayout* horizontalLayout_2;
QToolButton* toolButton;
horizontalLayout = new QHBoxLayout(this);
frame = new QFrame(this);
@ -83,7 +82,7 @@ ClickToFlash::ClickToFlash(const QUrl &pluginUrl, const QStringList &argumentNam
horizontalLayout->setContentsMargins(0,0,0,0);
horizontalLayout_2->setContentsMargins(0,0,0,0);
connect(toolButton, SIGNAL(clicked(bool)), this, SLOT(load()));
connect(toolButton, SIGNAL(clicked()), this, SLOT(load()));
setMinimumSize(27,27);
setContextMenuPolicy(Qt::CustomContextMenu);
@ -109,10 +108,10 @@ void ClickToFlash::toWhitelist()
void ClickToFlash::hideAdBlocked()
{
findElement();
if (!m_element.isNull()) {
if (!m_element.isNull())
m_element.setAttribute("style", "display:none;");
//deleteLater(); //Well, it should be there, but therefore it sometimes crashes
}
//deleteLater(); //Well, it should be there, but therefore it sometimes crashes
}
void ClickToFlash::findElement()
@ -130,11 +129,14 @@ void ClickToFlash::findElement()
return;
QList<QWebFrame*> frames;
frames.append(view->page()->frameAt(view->mapFromGlobal(toolButton->mapToGlobal(toolButton->pos()))));
m_mainFrame = view->page()->mainFrame();
frames.append(m_mainFrame);
while (!frames.isEmpty()) {
QWebFrame* frame = frames.takeFirst();
if (!frame)
continue;
QWebElement docElement = frame->documentElement();
QWebElementCollection elements;

View File

@ -79,6 +79,7 @@ private:
QWebElement m_element;
QWebFrame* m_mainFrame;
QToolButton* toolButton;
/**
used to find the right QWebElement between the ones of the different plugins
*/