Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(879)

Unified Diff: ios/chrome/browser/passwords/password_controller.mm

Issue 2125653002: Fix current/new password assignment in iOS PasswordController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: length->!empty Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/passwords/password_controller.mm
diff --git a/ios/chrome/browser/passwords/password_controller.mm b/ios/chrome/browser/passwords/password_controller.mm
index fc5d885b3bc2553709c48354ab7457b59e3033a7..e3f2bc1e0e1bc98a6f521829fe84d2e9be06dbdb 100644
--- a/ios/chrome/browser/passwords/password_controller.mm
+++ b/ios/chrome/browser/passwords/password_controller.mm
@@ -691,37 +691,40 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) {
form->password_value = values[0];
break;
case 2: {
- if (values[0] == values[1]) {
- // Treat two identical passwords as a single password.
- form->password_element = elements[0];
- form->password_value = values[0];
- } else {
- // Assume first is old password, second is new (no choice but to guess).
+ if (!values[0].empty() && values[0] == values[1]) {
+ // Treat two identical passwords as a single password new password, with
+ // confirmation. This can be either be a sign-up form or a password
+ // change form that does not ask for a new password.
form->new_password_element = elements[0];
form->new_password_value = values[0];
- form->password_element = elements[1];
- form->password_value = values[1];
+ } else {
+ // Assume first is old password, second is new (no choice but to guess).
+ form->password_element = elements[0];
+ form->password_value = values[0];
+ form->new_password_element = elements[1];
+ form->new_password_value = values[1];
}
break;
default:
- if (values[0] == values[1] && values[0] == values[2]) {
- // All three passwords the same? Just treat as one and hope.
+ if (!values[0].empty() && values[0] == values[1] &&
+ values[0] == values[2]) {
+ // All three passwords the same? This does not make sense, do not
+ // add the password element.
+ break;
+ } else if (values[0] == values[1]) {
+ // First two the same and the third different implies that the old
+ // password is the duplicated one.
form->password_element = elements[0];
form->password_value = values[0];
- } else if (values[0] == values[1]) {
- // Two the same and one different -> old password is the duplicated
- // one.
- form->new_password_element = elements[0];
- form->new_password_value = values[0];
- form->password_element = elements[2];
- form->password_value = values[2];
+ form->new_password_element = elements[2];
+ form->new_password_value = values[2];
} else if (values[1] == values[2]) {
// Two the same and one different -> new password is the duplicated
// one.
- form->new_password_element = elements[0];
- form->new_password_value = values[0];
- form->password_element = elements[1];
- form->password_value = values[1];
+ form->password_element = elements[0];
+ form->password_value = values[0];
+ form->new_password_element = elements[1];
+ form->new_password_value = values[1];
} else {
// Three different passwords, or first and last match with middle
// different. No idea which is which, so no luck.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698