[epiphany] location-entry: Properly normalize URI for cut/copy



commit 8c36f9cbeea2c56709c7dc5f7fae17e96bd226ed
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Mon Feb 8 19:31:27 2016 -0600

    location-entry: Properly normalize URI for cut/copy
    
    761d2fa %-encodes too much, including the ? in query parameters, and the
     # before the fragment.
    
    I wonder if I will ever again attempt to put a # in the first column of
    a git commit message. Can't say I've ever wanted to do that before.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=761660

 lib/ephy-uri-helpers.c            |   19 +++++++++++++++++++
 lib/ephy-uri-helpers.h            |    1 +
 lib/widgets/ephy-location-entry.c |    5 ++---
 3 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/lib/ephy-uri-helpers.c b/lib/ephy-uri-helpers.c
index 1ffa9c9..95b258f 100644
--- a/lib/ephy-uri-helpers.c
+++ b/lib/ephy-uri-helpers.c
@@ -261,4 +261,23 @@ ephy_uri_decode (const char *uri_string)
   return decoded_uri ? decoded_uri : g_strdup (uri_string);
 }
 
+char *
+ephy_uri_normalize (const char *uri_string)
+{
+  SoupURI *uri;
+  char *encoded_uri;
+
+  if (!uri_string || !*uri_string)
+    return NULL;
+
+  uri = soup_uri_new (uri_string);
+  if (!uri)
+    return g_strdup (uri_string);
+
+  encoded_uri = soup_uri_normalize (uri_string, NULL);
+  soup_uri_free (uri);
+
+  return encoded_uri;
+}
+
 /* vim: set sw=2 ts=2 sts=2 et: */
diff --git a/lib/ephy-uri-helpers.h b/lib/ephy-uri-helpers.h
index 2603b47..e7fffa1 100644
--- a/lib/ephy-uri-helpers.h
+++ b/lib/ephy-uri-helpers.h
@@ -25,6 +25,7 @@ G_BEGIN_DECLS
 
 char *ephy_remove_tracking_from_uri (const char *uri);
 char *ephy_uri_decode (const char *uri);
+char *ephy_uri_normalize (const char *uri);
 
 G_END_DECLS
 
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index 8dd3209..818348f 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -29,6 +29,7 @@
 #include "ephy-gui.h"
 #include "ephy-lib-type-builtins.h"
 #include "ephy-signal-accumulator.h"
+#include "ephy-uri-helpers.h"
 
 #include <gdk/gdkkeysyms.h>
 #include <glib/gi18n.h>
@@ -220,9 +221,7 @@ ephy_location_entry_copy_clipboard (GtkEntry *entry)
        if (start == 0)
        {
                char *tmp = text;
-               text = g_uri_escape_string (tmp,
-                                           G_URI_RESERVED_CHARS_ALLOWED_IN_PATH,
-                                           FALSE /* allow_utf8 */);
+               text = ephy_uri_normalize (tmp);
                g_free (tmp);
        }
 


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