[epiphany/mcatanzaro/password-fixes: 4/6] password-manager: Fix preconditions of ephy_password_manager_save()



commit 19d4ef2e4956860466f3bc6c2d986f6beff6ce85
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Tue Nov 13 15:48:04 2018 -0600

    password-manager: Fix preconditions of ephy_password_manager_save()
    
    password_field is always required because it's impossible to autofill a
    password without it. Also, we already know password is valid because we
    just asserted that, so the password_field check here doesn't make sense.
    
    For username, which is optional, we'll either allow both username and
    username_field, or neither of them.

 lib/sync/ephy-password-manager.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/lib/sync/ephy-password-manager.c b/lib/sync/ephy-password-manager.c
index 35cc386e3..2335b119d 100644
--- a/lib/sync/ephy-password-manager.c
+++ b/lib/sync/ephy-password-manager.c
@@ -474,9 +474,15 @@ ephy_password_manager_save (EphyPasswordManager *self,
   g_assert (EPHY_IS_PASSWORD_MANAGER (self));
   g_assert (origin);
   g_assert (target_origin);
+
+  /* Although we don't enforce these requirements for Firefox passwords,
+   * any password saved by Epiphany must have both password and
+   * password_field, so that it can be filled in. username and
+   * username_field are optional, but if one is provided, both must be.
+   */
   g_assert (password);
-  g_assert (!username_field || username);
-  g_assert (!password_field || password);
+  g_assert (password_field);
+  g_assert ((username && username_field) || (!username && !username_field));
 
   if (!is_new) {
     LOG ("Updating password for (%s, %s, %s, %s, %s)",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]