[epiphany] ephy-uri-helpers: Dot no modify the URI when it doesn't have garbage



commit ea6537f38237f4e5cfb424ec793c7f0aee4e6feb
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Tue May 20 19:24:51 2014 +0200

    ephy-uri-helpers: Dot no modify the URI when it doesn't have garbage
    
    We are currently decoding/encoding the uri query and returning it
    unchanged when it doesn't have garbage. We should return NULL instead in
    such case.
    This fixes the session management issues in some sites like gmail, but
    because the URLs processed don't actually have garbage. A URL with
    garbage and an underscore will still fail. This patch adds a unit test
    cover that particular case.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=730464

 lib/ephy-uri-helpers.c        |   20 +++++++++++++-------
 tests/ephy-uri-helpers-test.c |    4 ++++
 2 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/lib/ephy-uri-helpers.c b/lib/ephy-uri-helpers.c
index 2697dfa..5806e6f 100644
--- a/lib/ephy-uri-helpers.c
+++ b/lib/ephy-uri-helpers.c
@@ -223,6 +223,7 @@ ephy_remove_tracking_from_uri (const char *uri_string)
   GList *items, *new_items, *l;
   const char *query, *host;
   char *new_query;
+  gboolean has_garbage = FALSE;
   char *ret = NULL;
 
   uri = soup_uri_new (uri_string);
@@ -241,20 +242,25 @@ ephy_remove_tracking_from_uri (const char *uri_string)
   new_items = NULL;
   for (l = items; l != NULL; l = l->next) {
     QueryItem *item = l->data;
+
     if (!is_garbage (item->name, host))
       new_items = g_list_prepend (new_items, item);
+    else
+      has_garbage = TRUE;
   }
-  new_items = g_list_reverse (new_items);
 
-  new_query = query_encode (new_items);
+  if (has_garbage) {
+    new_items = g_list_reverse (new_items);
+    new_query = query_encode (new_items);
 
-  g_list_free_full (items, (GDestroyNotify) query_item_free);
-  g_list_free (new_items);
+    soup_uri_set_query (uri, new_query);
+    g_free (new_query);
 
-  soup_uri_set_query (uri, new_query);
-  g_free (new_query);
+    ret = soup_uri_to_string (uri, FALSE);
+  }
 
-  ret = soup_uri_to_string (uri, FALSE);
+  g_list_free_full (items, (GDestroyNotify) query_item_free);
+  g_list_free (new_items);
 
 bail:
   soup_uri_free (uri);
diff --git a/tests/ephy-uri-helpers-test.c b/tests/ephy-uri-helpers-test.c
index b17334b..1d9fc8d 100644
--- a/tests/ephy-uri-helpers-test.c
+++ b/tests/ephy-uri-helpers-test.c
@@ -47,6 +47,10 @@ test_ephy_uri_helpers_remove_tracking (void)
     /* https://bugzilla.gnome.org/show_bug.cgi?id=724724 */
     { "http://git.savannah.gnu.org/gitweb/?p=grep.git;a=commit;h=97318f5e59a1ef6feb8a378434a00932a3fc1e0b";,
       "http://git.savannah.gnu.org/gitweb/?p=grep.git;a=commit;h=97318f5e59a1ef6feb8a378434a00932a3fc1e0b"},
+    /* https://bugzilla.gnome.org/show_bug.cgi?id=730464 */
+    { 
"https://mail.google.com/mail/u/0/?ui=2&ik=37373eb942&rid=7cea..&auto=1&view=lno&_reqid=1168127&pcd=1&mb=0&rt=j";,
+      
"https://mail.google.com/mail/u/0/?ui=2&ik=37373eb942&rid=7cea..&auto=1&view=lno&_reqid=1168127&pcd=1&mb=0&rt=j";
 },
+    { "http://www.test.com/?utm_source=feedburner&view=lno&_reqid=1234";, 
"http://www.test.com/?view=lno&_reqid=1234"; },
   };
   guint i;
 


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