[epiphany] Epiphany not detecting form controls created by JS frameworks



commit 869ba52e787363fbaa5f30967bd99bc41b14cdb0
Author: Sergio Villar Senin <svillar igalia com>
Date:   Fri Oct 28 14:41:08 2016 +0200

    Epiphany not detecting form controls created by JS frameworks
    
    This is the first patch from a set of 3 which removes the dependency with
    form_password. We don't actually need a named password field in forms in
    order to store/restore authentication data.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=773327

 embed/web-extension/ephy-web-extension.c |    8 +++++---
 lib/ephy-form-auth-data.c                |   29 +++++++++++++----------------
 2 files changed, 18 insertions(+), 19 deletions(-)
---
diff --git a/embed/web-extension/ephy-web-extension.c b/embed/web-extension/ephy-web-extension.c
index 5debbc9..6627822 100644
--- a/embed/web-extension/ephy-web-extension.c
+++ b/embed/web-extension/ephy-web-extension.c
@@ -404,15 +404,17 @@ ephy_form_auth_data_compare (EphyFormAuthData  *form_data,
                              EphyEmbedFormAuth *form_auth)
 {
   WebKitDOMNode *username_node;
+  WebKitDOMNode *password_node;
   char *username_field_name = NULL;
-  char *password_field_name;
+  char *password_field_name = NULL;
   gboolean retval;
 
   username_node = ephy_embed_form_auth_get_username_node (form_auth);
   if (username_node)
     g_object_get (username_node, "name", &username_field_name, NULL);
-  g_object_get (ephy_embed_form_auth_get_password_node (form_auth),
-                "name", &password_field_name, NULL);
+  password_node = ephy_embed_form_auth_get_password_node (form_auth);
+  if (password_node)
+    g_object_get (password_node, "name", &password_field_name, NULL);
 
   retval = g_strcmp0 (username_field_name, form_data->form_username) == 0 &&
            g_strcmp0 (password_field_name, form_data->form_password) == 0;
diff --git a/lib/ephy-form-auth-data.c b/lib/ephy-form-auth-data.c
index 7af56d9..6896016 100644
--- a/lib/ephy-form-auth-data.c
+++ b/lib/ephy-form-auth-data.c
@@ -65,19 +65,18 @@ ephy_form_auth_data_get_secret_attributes_table (const char *uri,
                                                  const char *field_password,
                                                  const char *username)
 {
+  GHashTable *attributes;
+  attributes = secret_attributes_build (EPHY_FORM_PASSWORD_SCHEMA,
+                                        URI_KEY, uri,
+                                        username ? USERNAME_KEY : NULL, username,
+                                        NULL);
+
   if (field_username)
-    return secret_attributes_build (EPHY_FORM_PASSWORD_SCHEMA,
-                                    URI_KEY, uri,
-                                    FORM_USERNAME_KEY, field_username,
-                                    FORM_PASSWORD_KEY, field_password,
-                                    username ? USERNAME_KEY : NULL, username,
-                                    NULL);
-  else
-    return secret_attributes_build (EPHY_FORM_PASSWORD_SCHEMA,
-                                    URI_KEY, uri,
-                                    FORM_PASSWORD_KEY, field_password,
-                                    username ? USERNAME_KEY : NULL, username,
-                                    NULL);
+    g_hash_table_insert (attributes, g_strdup (FORM_USERNAME_KEY), g_strdup (field_username));
+  if (field_password)
+    g_hash_table_insert (attributes, g_strdup (FORM_PASSWORD_KEY), g_strdup (field_password));
+
+  return attributes;
 }
 
 static void
@@ -113,9 +112,9 @@ ephy_form_auth_data_store (const char         *uri,
   GTask *task;
 
   g_return_if_fail (uri);
-  g_return_if_fail (form_password);
   g_return_if_fail (password);
-  g_return_if_fail ((form_username && username) || (!form_username && !username));
+  g_return_if_fail (!form_username || username);
+  g_return_if_fail (!form_password || password);
 
   fake_uri = soup_uri_new (uri);
   g_return_if_fail (fake_uri);
@@ -241,7 +240,6 @@ ephy_form_auth_data_query (const char                   *uri,
   GHashTable *attributes;
 
   g_return_if_fail (uri);
-  g_return_if_fail (form_password);
 
   key = soup_uri_new (uri);
   g_return_if_fail (key);
@@ -401,7 +399,6 @@ ephy_form_auth_data_cache_add (EphyFormAuthDataCache *cache,
 
   g_return_if_fail (cache);
   g_return_if_fail (uri);
-  g_return_if_fail (form_password);
 
   data = ephy_form_auth_data_new (form_username, form_password, username);
   l = g_hash_table_lookup (cache->form_auth_data_map, uri);


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