mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
Properly export form data if password input is the only input in form.
This commit is contained in:
parent
4f3c8b0d00
commit
4fc6686185
@ -5,5 +5,5 @@ cd ../tests/autotests
|
||||
qmake DEFINES+=NO_SYSTEM_DATAPATH && make
|
||||
cd ../../bin
|
||||
|
||||
clear
|
||||
./autotests
|
||||
exit $?
|
||||
|
@ -43,6 +43,10 @@ PageFormData PageFormCompleter::extractFormData(const QByteArray &postData) cons
|
||||
QByteArray data = convertWebKitFormBoundaryIfNecessary(postData);
|
||||
PageFormData formData = {false, QString(), QString(), data};
|
||||
|
||||
if (data.isEmpty()) {
|
||||
return formData;
|
||||
}
|
||||
|
||||
if (!data.contains('=')) {
|
||||
qDebug() << "PageFormCompleter: Invalid form data" << data;
|
||||
return formData;
|
||||
@ -88,7 +92,7 @@ PageFormData PageFormCompleter::extractFormData(const QByteArray &postData) cons
|
||||
<< "input[type=\"text\"][name*=\"name\"]"
|
||||
<< "input[type=\"text\"]"
|
||||
<< "input[type=\"email\"]"
|
||||
<< "input:not([type=\"hidden\"])";
|
||||
<< "input:not([type=\"hidden\"][type=\"password\"])";
|
||||
|
||||
foreach(const QString & selector, selectors) {
|
||||
const QWebElementCollection &inputs = foundForm.findAll(selector);
|
||||
@ -107,10 +111,6 @@ PageFormData PageFormCompleter::extractFormData(const QByteArray &postData) cons
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
return formData;
|
||||
}
|
||||
|
||||
formData.found = true;
|
||||
formData.username = usernameValue;
|
||||
formData.password = passwordValue;
|
||||
|
@ -189,6 +189,26 @@ void FormCompleterTest::extractFormTest3()
|
||||
QCOMPARE(form.password, QString("tst_password"));
|
||||
}
|
||||
|
||||
void FormCompleterTest::extractFormTest4()
|
||||
{
|
||||
// Test extracting form that contains only password
|
||||
// as editable input
|
||||
|
||||
QByteArray data = "username=tst_username&password=tst_password";
|
||||
|
||||
QString html = "<form name='form2' method='post' action='foo2.php'>"
|
||||
"<input id='id3' type='hidden' name='username' value='tst_username'>"
|
||||
"<input id='id4' type='password' name='password' value='tst_password'>"
|
||||
"<input type='submit' value='submit' name='submit'>"
|
||||
"</form>";
|
||||
|
||||
PageFormData form = extractFormData(html, data);
|
||||
|
||||
QVERIFY(form.found == true);
|
||||
QCOMPARE(form.username, QString());
|
||||
QCOMPARE(form.password, QString("tst_password"));
|
||||
}
|
||||
|
||||
void FormCompleterTest::completeWithData(const QString &html, const QByteArray &data)
|
||||
{
|
||||
view->setHtml(html);
|
||||
|
@ -41,6 +41,7 @@ private slots:
|
||||
void extractFormTest1();
|
||||
void extractFormTest2();
|
||||
void extractFormTest3();
|
||||
void extractFormTest4();
|
||||
|
||||
private:
|
||||
void completeWithData(const QString &html, const QByteArray &data);
|
||||
|
Loading…
Reference in New Issue
Block a user