Title: [135699] trunk/Source/WebKit/blackberry
Revision
135699
Author
jonathan.d...@torchmobile.com.cn
Date
2012-11-26 02:53:58 -0800 (Mon, 26 Nov 2012)

Log Message

[BlackBerry] Should not autofill username and password when there're more than one password inputs on the same page
https://bugs.webkit.org/show_bug.cgi?id=103104

Reviewed by Rob Buis.

RIM PR: 245334
Added the oldPassword detection back into the password input
detection logic, which was removed for simplicity when imported
those pieces of codes from Chromium. And we won't do autofill
when there're more than one password field detected.

Internally reviewed by Rob Buis.

* WebCoreSupport/CredentialTransformData.cpp:
(WebCore::CredentialTransformData::CredentialTransformData):
(WebCore::CredentialTransformData::findPasswordFormFields):
* WebCoreSupport/CredentialTransformData.h:
(CredentialTransformData):
* WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
(WebCore::FrameLoaderClientBlackBerry::dispatchWillSendSubmitEvent):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/ChangeLog (135698 => 135699)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-11-26 10:46:59 UTC (rev 135698)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-11-26 10:53:58 UTC (rev 135699)
@@ -1,3 +1,26 @@
+2012-11-26  Jonathan Dong  <jonathan.d...@torchmobile.com.cn>
+
+        [BlackBerry] Should not autofill username and password when there're more than one password inputs on the same page
+        https://bugs.webkit.org/show_bug.cgi?id=103104
+
+        Reviewed by Rob Buis.
+
+        RIM PR: 245334
+        Added the oldPassword detection back into the password input
+        detection logic, which was removed for simplicity when imported
+        those pieces of codes from Chromium. And we won't do autofill
+        when there're more than one password field detected.
+
+        Internally reviewed by Rob Buis.
+
+        * WebCoreSupport/CredentialTransformData.cpp:
+        (WebCore::CredentialTransformData::CredentialTransformData):
+        (WebCore::CredentialTransformData::findPasswordFormFields):
+        * WebCoreSupport/CredentialTransformData.h:
+        (CredentialTransformData):
+        * WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
+        (WebCore::FrameLoaderClientBlackBerry::dispatchWillSendSubmitEvent):
+
 2012-11-25  Jacky Jiang  <zhaji...@rim.com>
 
         [BlackBerry] Get rid of resetBitmapZoomScale()

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/CredentialTransformData.cpp (135698 => 135699)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/CredentialTransformData.cpp	2012-11-26 10:46:59 UTC (rev 135698)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/CredentialTransformData.cpp	2012-11-26 10:53:58 UTC (rev 135699)
@@ -64,10 +64,10 @@
 
 // Helper method to determine which password is the main one, and which is
 // an old password (e.g on a "make new password" form), if any.
-bool locateSpecificPasswords(Vector<HTMLInputElement*>& passwords,
-                             HTMLInputElement** password)
+bool locateSpecificPasswords(Vector<HTMLInputElement*>& passwords, HTMLInputElement** password, HTMLInputElement** oldPassword)
 {
     ASSERT(password);
+    ASSERT(oldPassword);
 
     switch (passwords.size()) {
     case 1:
@@ -80,6 +80,7 @@
             *password = passwords[0];
         else {
             // Assume first is old password, second is new (no choice but to guess).
+            *oldPassword = passwords[0];
             *password = passwords[1];
         }
         break;
@@ -90,9 +91,12 @@
             *password = passwords[0];
         } else if (passwords[0]->value() == passwords[1]->value()) {
             // Two the same and one different -> old password is duplicated one.
+            *oldPassword = passwords[0];
             *password = passwords[2];
-        } else if (passwords[1]->value() == passwords[2]->value())
+        } else if (passwords[1]->value() == passwords[2]->value()) {
+            *oldPassword = passwords[0];
             *password = passwords[1];
+        }
         else {
             // Three different passwords, or first and last match with middle
             // different. No idea which is which, so no luck.
@@ -107,9 +111,10 @@
 
 } // namespace
 
-CredentialTransformData::CredentialTransformData(HTMLFormElement* form)
+CredentialTransformData::CredentialTransformData(HTMLFormElement* form, bool isForSaving)
     : m_userNameElement(0)
     , m_passwordElement(0)
+    , m_oldPasswordElement(0)
     , m_isValid(false)
 {
     ASSERT(form);
@@ -128,6 +133,10 @@
     if (!findPasswordFormFields(form))
         return;
 
+    // Won't restore password if there're two password inputs on the page.
+    if (!isForSaving && m_oldPasswordElement)
+        return;
+
     m_url = stripURL(fullOrigin);
     m_action = stripURL(fullAction);
     m_protectionSpace = ProtectionSpace(m_url.host(), m_url.port(), ProtectionSpaceServerHTTP, "Form", ProtectionSpaceAuthenticationSchemeHTMLForm);
@@ -142,6 +151,7 @@
     , m_credential(credential)
     , m_userNameElement(0)
     , m_passwordElement(0)
+    , m_oldPasswordElement(0)
     , m_isValid(true)
 {
 }
@@ -227,7 +237,7 @@
     if (!m_userNameElement)
         return false;
 
-    if (!locateSpecificPasswords(passwords, &(m_passwordElement)))
+    if (!locateSpecificPasswords(passwords, &m_passwordElement, &m_oldPasswordElement))
         return false;
     return true;
 }

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/CredentialTransformData.h (135698 => 135699)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/CredentialTransformData.h	2012-11-26 10:46:59 UTC (rev 135698)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/CredentialTransformData.h	2012-11-26 10:53:58 UTC (rev 135699)
@@ -29,7 +29,7 @@
 struct CredentialTransformData {
     // If the provided form is suitable for password completion, isValid() will
     // return true;
-    CredentialTransformData(HTMLFormElement*);
+    CredentialTransformData(HTMLFormElement*, bool isForSaving = false);
     CredentialTransformData(const KURL&, const ProtectionSpace&, const Credential&);
 
     // If creation failed, return false.
@@ -49,6 +49,7 @@
     mutable Credential m_credential;
     HTMLInputElement* m_userNameElement;
     HTMLInputElement* m_passwordElement;
+    HTMLInputElement* m_oldPasswordElement;
     bool m_isValid;
 };
 

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp (135698 => 135699)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp	2012-11-26 10:46:59 UTC (rev 135698)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp	2012-11-26 10:53:58 UTC (rev 135699)
@@ -766,7 +766,7 @@
             m_webPagePrivate->m_autofillManager->saveTextFields(prpFormState->form());
 #if ENABLE(BLACKBERRY_CREDENTIAL_PERSIST)
         if (m_webPagePrivate->m_webSettings->isCredentialAutofillEnabled())
-            credentialManager().saveCredentialIfConfirmed(m_webPagePrivate, CredentialTransformData(prpFormState->form()));
+            credentialManager().saveCredentialIfConfirmed(m_webPagePrivate, CredentialTransformData(prpFormState->form(), true));
 #endif
     }
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to