From f8bf87ecf97cb56f676b71d4b704453cfd5f568f Mon Sep 17 00:00:00 2001 From: Alexander Butenko Date: Fri, 23 Jul 2010 09:48:45 -0400 Subject: [PATCH] Dont unescape URIs which are not escaped sokoke_uri_unescape_string handles that and handles '+' the way we want. --- midori/midori-locationaction.c | 3 ++- midori/sokoke.c | 19 ++++++++++++++++++- midori/sokoke.h | 3 +++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c index 34772b24..29484d9e 100644 --- a/midori/midori-locationaction.c +++ b/midori/midori-locationaction.c @@ -455,7 +455,8 @@ midori_location_action_popup_timeout_cb (gpointer data) icon = action->default_icon; if (type == 1 /* history_view */) { - unescaped_uri = g_uri_unescape_string ((const char*)uri, ""); + unescaped_uri = sokoke_uri_unescape_string ((const char*)uri); + gtk_list_store_insert_with_values (store, NULL, matches, URI_COL, unescaped_uri, TITLE_COL, title, YALIGN_COL, 0.25, FAVICON_COL, icon, -1); diff --git a/midori/sokoke.c b/midori/sokoke.c index 99bc96ec..909f7113 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -737,6 +737,22 @@ sokoke_magic_uri (const gchar* uri) return NULL; } +/** + * sokoke_uri_unescape_string: + * @uri: an URI string + * + * Unescape @uri if needed, and pass through '+'. + * + * Return value: a newly allocated URI + **/ +gchar* +sokoke_uri_unescape_string (const gchar* uri) +{ + if (strchr (uri,'%')) + return g_uri_unescape_string (uri, "+"); + return g_strdup (uri); +} + /** * sokoke_format_uri_for_display: * @uri: an URI string @@ -749,9 +765,10 @@ sokoke_magic_uri (const gchar* uri) gchar* sokoke_format_uri_for_display (const gchar* uri) { + gchar* unescaped; if (uri && g_str_has_prefix (uri, "http://")) { - gchar* unescaped = g_uri_unescape_string (uri, "+"); + gchar* unescaped = sokoke_uri_unescape_string (uri); #ifdef HAVE_LIBSOUP_2_27_90 gchar* path = NULL; gchar* hostname; diff --git a/midori/sokoke.h b/midori/sokoke.h index 99d91e01..105aed0c 100644 --- a/midori/sokoke.h +++ b/midori/sokoke.h @@ -113,6 +113,9 @@ sokoke_uri_to_ascii (const gchar* uri); gchar* sokoke_magic_uri (const gchar* uri); +gchar* +sokoke_uri_unescape_string (const gchar* uri); + gchar* sokoke_format_uri_for_display (const gchar* uri); -- 2.39.5