rendered paste bodydiff --git a/embed/ephy-embed-single.c b/embed/ephy-embed-single.cindex 3b13e4f..f214064 100644--- a/embed/ephy-embed-single.c+++ b/embed/ephy-embed-single.c@@ -1,6 +1,8 @@ /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */+/* vim: set sw=2 ts=2 sts=2 et: */ /* * Copyright © 2000-2003 Marco Pesenti Gritti+ * Copyright © 2010 Igalia S.L. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by@@ -174,10 +176,14 @@ get_attr_cb (GnomeKeyringResult result, const char *form_username, *form_password; GHashTable *t; SoupURI *uri = soup_uri_new (server);+ t = soup_form_decode (uri->query); form_username = g_hash_table_lookup (t, FORM_USERNAME_KEY); form_password = g_hash_table_lookup (t, FORM_PASSWORD_KEY);- ephy_embed_single_add_form_auth (single, uri->host, form_username, form_password, username);++ ephy_embed_single_add_form_auth (single, server, form_username,+ form_password, username);+ soup_uri_free (uri); g_hash_table_destroy (t); }@@ -613,6 +619,8 @@ ephy_embed_single_open_window (EphyEmbedSingle *single, * ephy_embed_single_get_form_auth: * @single: an #EphyEmbedSingle * @uri: the URI of a web page+ * @form_username: username form field name+ * @form_password: password form field name * * Gets a #GSList of all stored login/passwords, in * #EphyEmbedSingleFormAuthData format, for any form in @uri, or %NULL@@ -620,22 +628,54 @@ ephy_embed_single_open_window (EphyEmbedSingle *single, * * The #EphyEmbedSingleFormAuthData structs and the #GSList are owned * by @single and should not be freed by the user.- * + *+ * Notice that @uri's path is removed with #soup_uri_set_path, so you don't+ * need to clean it yourself.+ *+ * Remember that internally we identify logins with a host+encoded fields+ * string, so for example in host "a.com" the form with fields "user" and+ * "pass" is stored in the keyring and in the cache as+ * "http://a.com/?form_username=user&form_password=pass".+ * * Returns: #GSList with the possible auto-fills for the forms in * @uri, or %NULL **/ GSList * ephy_embed_single_get_form_auth (EphyEmbedSingle *single,- const char *uri)+ const char *uri,+ const char *form_username,+ const char *form_password) { EphyEmbedSinglePrivate *priv;+ GSList *slist = NULL;+ SoupURI *query;+ char *query_uri; g_return_val_if_fail (EPHY_IS_EMBED_SINGLE (single), NULL); g_return_val_if_fail (uri, NULL);+ g_return_val_if_fail (form_username, NULL);+ g_return_val_if_fail (form_password, NULL); priv = single->priv; - return g_hash_table_lookup (priv->form_auth_data, uri);+ query = soup_uri_new (uri);+ soup_uri_set_path (query, NULL);++ if (g_str_equal (query->scheme, SOUP_URI_SCHEME_HTTPS))+ soup_uri_set_scheme (query, SOUP_URI_SCHEME_HTTP);++ soup_uri_set_query_from_fields (query,+ FORM_USERNAME_KEY, form_username,+ FORM_PASSWORD_KEY, form_password,+ NULL);++ query_uri = soup_uri_to_string (query, FALSE);+ slist = g_hash_table_lookup (priv->form_auth_data, query_uri);++ g_free (query_uri);+ soup_uri_free (query);++ return slist; } /**@@ -648,6 +688,13 @@ ephy_embed_single_get_form_auth (EphyEmbedSingle *single, * * Adds a new entry to the local cache of form auth data stored in * @single.+ * Notice that @uri's path is removed with #soup_uri_set_path, so you don't+ * need to clean it yourself.+ *+ * Remember that internally we identify logins with a host+encoded fields+ * string, so for example in host "a.com" the form with fields "user" and+ * "pass" is stored in the keyring and in the cache as+ * "http://a.com/?form_username=user&form_password=pass". * **/ void@@ -660,6 +707,8 @@ ephy_embed_single_add_form_auth (EphyEmbedSingle *single, EphyEmbedSingleFormAuthData *form_data; EphyEmbedSinglePrivate *priv; GSList *l;+ SoupURI *query;+ char *query_uri; g_return_if_fail (EPHY_IS_EMBED_SINGLE (single)); g_return_if_fail (uri);@@ -669,13 +718,28 @@ ephy_embed_single_add_form_auth (EphyEmbedSingle *single, priv = single->priv; - LOG ("Appending: name field: %s / pass field: %s / username: %s / uri: %s", form_username, form_password, username, uri);+ LOG ("Appending: name field: %s / pass field: %s / username: %s / uri: %s",+ form_username, form_password, username, uri); form_data = form_auth_data_new (form_username, form_password, username);- l = g_hash_table_lookup (priv->form_auth_data,- uri);++ query = soup_uri_new (uri);+ soup_uri_set_path (query, NULL);++ if (g_str_equal (query->scheme, SOUP_URI_SCHEME_HTTPS))+ soup_uri_set_scheme (query, SOUP_URI_SCHEME_HTTP);++ soup_uri_set_query_from_fields (query,+ FORM_USERNAME_KEY, form_username,+ FORM_PASSWORD_KEY, form_password,+ NULL);++ query_uri = soup_uri_to_string (query, FALSE);++ l = g_hash_table_lookup (priv->form_auth_data, query_uri); l = g_slist_append (l, form_data);- g_hash_table_replace (priv->form_auth_data,- g_strdup (uri),- l);+ g_hash_table_replace (priv->form_auth_data, g_strdup (query_uri), l);++ g_free (query_uri);+ soup_uri_free (query); }diff --git a/embed/ephy-embed-single.h b/embed/ephy-embed-single.hindex 3210105..b0b28e0 100644--- a/embed/ephy-embed-single.h+++ b/embed/ephy-embed-single.h@@ -98,7 +98,9 @@ void ephy_embed_single_set_network_status (EphyEmbedSingle *single, gboolean ephy_embed_single_get_network_status (EphyEmbedSingle *single); GSList * ephy_embed_single_get_form_auth (EphyEmbedSingle *single,- const char *uri);+ const char *uri,+ const char *form_username,+ const char *form_password); void ephy_embed_single_add_form_auth (EphyEmbedSingle *single, const char *uri,diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.cindex cbb70c9..2248642 100644--- a/embed/ephy-web-view.c+++ b/embed/ephy-web-view.c@@ -859,7 +859,6 @@ store_password (GtkInfoBar *info_bar, gint response_id, gpointer data) char *name_field_value = store_data->name_value; char *password_field_name = store_data->password_field; char *password_field_value = store_data->password_value;- SoupURI *soup_uri; /* We are no longer showing a store password infobar */ web_view->priv->password_info_bar = NULL;@@ -879,14 +878,11 @@ store_password (GtkInfoBar *info_bar, gint response_id, gpointer data) password_field_value); /* Update internal caching */- soup_uri = soup_uri_new (uri);- ephy_embed_single_add_form_auth (EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (embed_shell)),- soup_uri->host,+ uri, name_field_name, password_field_name, name_field_value);- soup_uri_free (soup_uri); store_password_data_free (store_data); gtk_widget_destroy (GTK_WIDGET (info_bar));@@ -1111,40 +1107,48 @@ pre_fill_form (JSContextRef js_context, JSObjectRef password_element, EphyWebView *view) {+ EphyEmbedSingle *single;+ char *username_field_name;+ char *password_field_name;+ const char *uri = NULL; GSList *l = NULL;- SoupURI *uri = NULL; GSList *p = NULL; - uri = soup_uri_new (webkit_web_view_get_uri (WEBKIT_WEB_VIEW (view)));- if (uri)- l = ephy_embed_single_get_form_auth (EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (embed_shell)), uri->host);+ single = EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (embed_shell));++ username_field_name = js_get_element_attribute (js_context,+ username_element, "name");+ password_field_name = js_get_element_attribute (js_context,+ password_element, "name");++ uri = webkit_web_view_get_uri (WEBKIT_WEB_VIEW (view));++ l = ephy_embed_single_get_form_auth (single, uri,+ username_field_name,+ password_field_name); for (p = l; p; p = p->next) { EphyEmbedSingleFormAuthData *data = (EphyEmbedSingleFormAuthData*)p->data;- char *username_field_name = js_get_element_attribute (js_context, username_element, "name");- char *password_field_name = js_get_element_attribute (js_context, password_element, "name");+ if (g_strcmp0 (username_field_name, data->form_username) == 0 && g_strcmp0 (password_field_name, data->form_password) == 0) { FillData *fill_data = g_slice_new (FillData);- char *uri_str = soup_uri_to_string (uri, FALSE); fill_data->context = js_context; fill_data->username_element = username_element; fill_data->password_element = password_element; - _ephy_profile_query_form_auth_data (uri_str,+ _ephy_profile_query_form_auth_data (uri, data->form_username, data->form_password, fill_form_cb, fill_data, fill_data_free);- g_free (uri_str); }- g_free (username_field_name);- g_free (password_field_name); } - soup_uri_free (uri);+ g_free (username_field_name);+ g_free (password_field_name); } static voiddiff --git a/lib/ephy-profile-migration.c b/lib/ephy-profile-migration.cindex 991a212..73584ef 100644--- a/lib/ephy-profile-migration.c+++ b/lib/ephy-profile-migration.c@@ -446,6 +446,8 @@ normalize_and_prepare_uri (SoupURI *uri, if (g_str_equal (uri->scheme, SOUP_URI_SCHEME_HTTPS)) soup_uri_set_scheme (uri, SOUP_URI_SCHEME_HTTP); + soup_uri_set_path (uri, NULL);+ /* Store the form login and password names encoded in the * URL. A bit of an abuse of keyring, but oh well */ soup_uri_set_query_from_fields (uri,