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



commit c103ea6b62d841df90243ddf8d70ec1979300e90
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]