From 77428fe44cece896019be5ce5c6f409f21298931 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Wed, 19 Oct 2011 09:53:18 +0200 Subject: [PATCH] Introduce Midori.URI to unitfy all URI logic sokoke_hostname_from_uri, sokoke_search_uri, sokoke_hostname_to_ascii and sokoke_unescape_uri_string are merged into Midori.URI. midori-core.h is the official API header for Vala now. --- katze/katze-utils.c | 10 +- katze/midori-uri.vala | 126 ++++++++++++++++++++ midori/main.c | 7 +- midori/midori-browser.c | 15 +-- midori/midori-locationaction.c | 6 +- midori/midori-searchaction.c | 5 +- midori/midori-view.c | 29 +++-- midori/midori.h | 1 + midori/sokoke.c | 206 +-------------------------------- midori/sokoke.h | 16 --- panels/midori-extensions.c | 3 +- tests/magic-uri.c | 7 +- 12 files changed, 171 insertions(+), 260 deletions(-) create mode 100644 katze/midori-uri.vala diff --git a/katze/katze-utils.c b/katze/katze-utils.c index 27366f28..687b728c 100644 --- a/katze/katze-utils.c +++ b/katze/katze-utils.c @@ -13,6 +13,7 @@ #include "katze-utils.h" #include "katze-array.h" +#include "midori-core.h" #include #include @@ -1518,12 +1519,7 @@ katze_uri_entry_changed_cb (GtkWidget* entry, GtkWidget* other_widget) { const gchar* uri = gtk_entry_get_text (GTK_ENTRY (entry)); - gboolean valid = g_str_has_prefix (uri, "http://") - || g_str_has_prefix (uri, "https://") - || g_str_has_prefix (uri, "file://") - || g_str_has_prefix (uri, "data:") - || g_str_has_prefix (uri, "about:") - || g_str_has_prefix (uri, "javascript:"); + gboolean valid = midori_uri_is_location (uri); if (*uri && !valid) { GdkColor bg_color = { 0 }; @@ -1540,7 +1536,7 @@ katze_uri_entry_changed_cb (GtkWidget* entry, } if (other_widget != NULL) - gtk_widget_set_sensitive (other_widget, *uri && valid); + gtk_widget_set_sensitive (other_widget, valid); } /** diff --git a/katze/midori-uri.vala b/katze/midori-uri.vala new file mode 100644 index 00000000..2653fbc5 --- /dev/null +++ b/katze/midori-uri.vala @@ -0,0 +1,126 @@ +/* + Copyright (C) 2011 Christian Dywan + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + See the file COPYING for the full license text. +*/ + +namespace GLib { + extern static string hostname_to_unicode (string hostname); + extern static string hostname_to_ascii (string hostname); +} + +namespace Midori { + public class URI : Object { + public static string parse (string? uri, out string path) { + /* path may be null. + If there's no hostname, the original URI is returned */ + if (uri == null) + return uri; + unowned string? hostname = uri.chr (-1, '/'); + if (hostname == null || hostname[1] != '/') + return uri; + hostname = hostname.offset (2); + if (&path != null) { + if ((path = hostname.chr (-1, '/')) != null) + return hostname.split ("/")[0]; + } + return hostname; + } + public static string to_ascii (string uri) { + /* Convert hostname to ASCII. */ + string? proto = null; + if (uri.chr (-1, '/') != null && uri.chr (-1, ':') != null) + proto = uri.split ("://")[0]; + string? path = null; + string hostname = parse (uri, out path); + string encoded = hostname_to_ascii (hostname); + if (encoded != null) { + return (proto ?? "") + + (proto != null ? "://" : "") + + encoded + path; + } + return uri; + } + public static string unescape (string uri) { + /* Unescape, pass through + and %20 */ + if (uri.chr (-1, '%') != null || uri.chr (-1, ' ') != null) { + /* Preserve %20 for pasting URLs into other windows */ + string? unescaped = GLib.Uri.unescape_string (uri, "+"); + if (unescaped == null) + return uri; + return unescaped.replace (" ", "%20"); + } + return uri; + } + public static string format_for_display (string? uri) { + /* Percent-decode and decode puniycode for user display */ + if (uri != null && uri.has_prefix ("http://")) { + string unescaped = unescape (uri); + if (unescaped == null) + return uri; + else if (!unescaped.validate ()) + return uri; + string path; + string hostname = parse (unescaped, out path); + string decoded = hostname_to_unicode (hostname); + if (decoded != null) + return "http://" + decoded + path; + return unescaped; + } + return uri; + } + public static string for_search (string? uri, string keywords) { + /* Take a search engine URI and insert specified keywords. + Keywords are percent-encoded. If the uri contains a %s + the keywords are inserted there, otherwise appended. */ + if (uri == null) + return keywords; + string escaped = GLib.Uri.escape_string (keywords, ":/", true); + if (uri.str ("%s") != null) + return uri.printf (escaped); + return uri + escaped; + } + public static bool is_blank (string? uri) { + return !(uri != null && uri != "" && !uri.has_prefix ("about:")); + } + public static bool is_resource (string? uri) { + return uri != null + && (uri.has_prefix ("http://") + || (uri.has_prefix ("data:") && uri.chr (-1, ';') != null) + || uri.has_prefix ("https://")); + } + public static bool is_location (string? uri) { + /* file:// is not considered a location for security reasons */ + return uri != null + && ((uri.str ("://") != null && uri.chr (-1, ' ') == null) + || uri.has_prefix ("about:") + || (uri.has_prefix ("data:") && uri.chr (-1, ';') != null) + || (uri.has_prefix ("geo:") && uri.chr (-1, ',') != null) + || uri.has_prefix ("javascript:")); + } + public static bool is_email (string? uri) { + return uri != null + && (uri.chr (-1, '@') != null || uri.has_prefix ("mailto:")) + /* :// and @ together would mean login credentials */ + && uri.str ("://") == null; + } + public static bool is_ip_address (string? uri) { + /* Quick check for IPv4 or IPv6, no validation. + FIXME: Schemes are not handled + hostname_is_ip_address () is not used because + we'd have to separate the path from the URI first. */ + return uri != null && uri[0].isdigit () + && (uri.chr (4, '.') != null || uri.chr (4, ':') != null); + } + public static bool is_valid (string? uri) { + return uri != null + && uri.chr (-1, ' ') == null + && (URI.is_location (uri) || uri.chr (-1, '.') != null); + } + } +} diff --git a/midori/main.c b/midori/main.c index faafa078..9373ded5 100644 --- a/midori/main.c +++ b/midori/main.c @@ -20,6 +20,7 @@ #include "midori-extensions.h" #include "midori-history.h" #include "midori-transfers.h" +#include #include "sokoke.h" @@ -1406,7 +1407,7 @@ midori_load_session (gpointer data) item = katze_array_get_nth_item (_session, 0); } midori_browser_set_current_page (browser, current); - if (!g_strcmp0 (katze_item_get_uri (item), "")) + if (midori_uri_is_blank (katze_item_get_uri (item))) midori_browser_activate_action (browser, "Location"); g_object_unref (settings); @@ -1528,9 +1529,9 @@ midori_prepare_uri (const gchar *uri) uri_ready = sokoke_magic_uri (uri); if (uri_ready) - return sokoke_uri_to_ascii (uri_ready); + return midori_uri_to_ascii (uri_ready); - return sokoke_uri_to_ascii (uri); + return midori_uri_to_ascii (uri); } #ifdef HAVE_SIGNAL_H diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 6ee7942b..008a8720 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -25,6 +25,7 @@ #include "midori-findbar.h" #include "midori-transferbar.h" #include "midori-platform.h" +#include "midori-core.h" #include "gtkiconentry.h" #include "marshal.h" @@ -382,7 +383,7 @@ _midori_browser_set_statusbar_text (MidoriBrowser* browser, gboolean is_location = widget && GTK_IS_ENTRY (widget) && GTK_IS_ALIGNMENT (gtk_widget_get_parent (widget)); - katze_assign (browser->statusbar_text, sokoke_format_uri_for_display (text)); + katze_assign (browser->statusbar_text, midori_uri_format_for_display (text)); if (!browser->show_statusbar && !is_location) { @@ -611,7 +612,7 @@ midori_view_notify_title_cb (GtkWidget* widget, proxy = midori_view_get_proxy_item (view); proxy_uri = katze_item_get_uri (proxy); if (proxy_uri && *proxy_uri && proxy_uri[1] && - !g_str_has_prefix (proxy_uri, "about:") && + !midori_uri_is_blank (proxy_uri) && (katze_item_get_meta_integer (proxy, "history-step") == -1)) { if (!katze_item_get_meta_boolean (proxy, "dont-write-history")) @@ -621,7 +622,7 @@ midori_view_notify_title_cb (GtkWidget* widget, } } else if (katze_item_get_name (proxy) && - !g_str_has_prefix (proxy_uri, "about:") && + !midori_uri_is_blank (proxy_uri) && (katze_item_get_meta_integer (proxy, "history-step") == 1)) { midori_browser_update_history_title (browser, proxy); @@ -3788,7 +3789,7 @@ _action_location_submit_uri (GtkAction* action, keywords = stripped_uri; search_uri = browser->location_entry_search; } - new_uri = sokoke_search_uri (search_uri, keywords); + new_uri = midori_uri_for_search (search_uri, keywords); if (browser->history != NULL) { @@ -3937,7 +3938,7 @@ _action_search_submit (GtkAction* action, else /* The location entry search is our fallback */ url = browser->location_entry_search; - search = sokoke_search_uri (url, keywords); + search = midori_uri_for_search (url, keywords); if (new_tab) midori_browser_add_uri (browser, search); @@ -3967,7 +3968,7 @@ _action_search_activate (GtkAction* action, /* Load default search engine in current tab */ uri = browser->location_entry_search; - search = sokoke_search_uri (uri ? uri : "", ""); + search = midori_uri_for_search (uri ? uri : "", ""); midori_browser_set_current_uri (browser, search); gtk_widget_grab_focus (midori_browser_get_current_tab (browser)); g_free (search); @@ -7140,7 +7141,7 @@ midori_browser_add_item (MidoriBrowser* browser, /* Blank pages should not be delayed */ if (katze_item_get_meta_integer (item, "delay") > 0 - && strcmp (uri, "about:blank") != 0 + && !midori_uri_is_blank (uri) && strncmp (uri, "pause:", 6) != 0) { gchar* new_uri = g_strdup_printf ("pause:%s", uri); diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c index 7969101e..0fc0374a 100644 --- a/midori/midori-locationaction.c +++ b/midori/midori-locationaction.c @@ -12,13 +12,13 @@ #include "midori-locationaction.h" -#include "gtk3-compat.h" #include "gtkiconentry.h" #include "marshal.h" #include "sokoke.h" #include "midori-browser.h" #include "midori-searchaction.h" #include "midori-platform.h" +#include #include #include @@ -508,7 +508,7 @@ midori_location_action_popup_timeout_cb (gpointer data) gchar* title; GdkPixbuf* icon; - uri = sokoke_search_uri (katze_item_get_uri (item), action->key); + uri = midori_uri_for_search (katze_item_get_uri (item), action->key); title = g_strdup_printf (_("Search with %s"), katze_item_get_name (item)); icon = midori_search_action_get_icon (item, action->treeview, NULL, FALSE); gtk_list_store_insert_with_values (store, NULL, matches + i, @@ -1079,7 +1079,7 @@ midori_location_entry_render_text_cb (GtkCellLayout* layout, keys = g_strsplit_set (key, " %", -1); g_free (key); - uri_temp = sokoke_uri_unescape_string (uri_escaped); + uri_temp = midori_uri_unescape (uri_escaped); g_free (uri_escaped); uri = g_strescape (uri_temp, NULL); g_free (uri_temp); diff --git a/midori/midori-searchaction.c b/midori/midori-searchaction.c index 41eb4de2..d7a2efc7 100644 --- a/midori/midori-searchaction.c +++ b/midori/midori-searchaction.c @@ -16,6 +16,7 @@ #include "marshal.h" #include "sokoke.h" #include "midori-platform.h" +#include "midori-core.h" #include #include @@ -407,11 +408,11 @@ midori_search_action_get_icon (KatzeItem* item, const gchar** icon_name, gboolean in_entry) { - const gchar* icon; + const gchar* icon = katze_item_get_uri (item); GdkScreen* screen; GtkIconTheme* icon_theme; - if ((icon = katze_item_get_uri (item)) && (g_strstr_len (icon, 8, "://"))) + if (midori_uri_is_resource (icon)) return katze_load_cached_icon (icon, widget); if (icon_name == NULL) diff --git a/midori/midori-view.c b/midori/midori-view.c index eb1acc32..73b35d44 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -20,6 +20,7 @@ #include "midori-browser.h" #include "midori-searchaction.h" #include "midori-platform.h" +#include "midori-core.h" #include "marshal.h" #include "sokoke.h" @@ -1064,7 +1065,7 @@ webkit_web_view_load_committed_cb (WebKitWebView* web_view, if (g_strcmp0 (uri, katze_item_get_uri (view->item))) { - katze_assign (view->uri, sokoke_format_uri_for_display (uri)); + katze_assign (view->uri, midori_uri_format_for_display (uri)); katze_item_set_uri (view->item, uri); } @@ -1362,7 +1363,7 @@ midori_view_web_view_database_quota_exceeded_cb (WebKitWebView* web_view, MidoriView* view) { const gchar* uri = webkit_web_frame_get_uri (web_frame); - const gchar* hostname = sokoke_hostname_from_uri (uri, NULL); + const gchar* hostname = midori_uri_parse (uri, NULL); gchar* message = g_strdup_printf (_("%s wants to save an HTML5 database."), hostname && *hostname ? hostname : uri); midori_view_add_info_bar (view, GTK_MESSAGE_QUESTION, message, @@ -1391,7 +1392,7 @@ midori_view_web_view_geolocation_decision_cb (WebKitWebView* w MidoriView* view) { const gchar* uri = webkit_web_frame_get_uri (web_frame); - const gchar* hostname = sokoke_hostname_from_uri (uri, NULL); + const gchar* hostname = midori_uri_parse (uri, NULL); gchar* message = g_strdup_printf (_("%s wants to know your location."), hostname && *hostname ? hostname : uri); midori_view_add_info_bar (view, GTK_MESSAGE_QUESTION, @@ -1774,12 +1775,12 @@ gtk_widget_button_press_event_cb (WebKitWebView* web_view, { gchar* search = katze_object_get_string ( view->settings, "location-entry-search"); - new_uri = sokoke_search_uri (search, uri); + new_uri = midori_uri_for_search (search, uri); g_free (search); } katze_assign (uri, new_uri); } - else if (!strstr (uri, "://")) + else if (!midori_uri_is_location (uri)) { g_free (uri); return FALSE; @@ -1935,7 +1936,7 @@ gtk_widget_key_press_event_cb (WebKitWebView* web_view, view->find_links, event->keyval == GDK_KEY_Return ); result = sokoke_js_script_eval (js_context, script, NULL); - if (result && strstr (result, "://")) + if (midori_uri_is_location (result)) { if (MIDORI_MOD_NEW_TAB (event->state)) { @@ -2157,7 +2158,7 @@ midori_web_view_menu_search_web_activate_cb (GtkWidget* widget, else g_object_get (view->settings, "location-entry-search", &search, NULL); - uri = sokoke_search_uri (search, view->selected_text); + uri = midori_uri_for_search (search, view->selected_text); g_free (search); g_signal_emit (view, signals[NEW_TAB], 0, uri, @@ -2489,10 +2490,9 @@ midori_view_populate_popup (MidoriView* view, G_CALLBACK (midori_web_view_menu_search_web_activate_cb), widget); g_strstrip (view->selected_text); - if (view->selected_text && !strchr (view->selected_text, ' ') - && (strchr (view->selected_text, '.') || g_strstr_len (view->selected_text, 9, "://"))) + if (midori_uri_is_valid (view->selected_text)) { - if (strchr (view->selected_text, '@')) + if (midori_uri_is_email (view->selected_text)) { gchar* text = g_strdup_printf (_("Send a message to %s"), view->selected_text); menuitem = midori_view_insert_menu_item (menu_shell, -1, @@ -3866,7 +3866,7 @@ midori_view_set_uri (MidoriView* view, } /* This is not prefectly elegant, but creating special pages inline is the simplest solution. */ - else if (g_str_has_prefix (uri, "error:") || g_str_has_prefix (uri, "about:")) + else if (g_str_has_prefix (uri, "error:") || midori_uri_is_blank (uri)) { data = NULL; if (!strncmp (uri, "error:nodocs ", 13)) @@ -4009,7 +4009,7 @@ midori_view_set_uri (MidoriView* view, } else { - katze_assign (view->uri, sokoke_format_uri_for_display (uri)); + katze_assign (view->uri, midori_uri_format_for_display (uri)); katze_item_set_uri (view->item, uri); katze_item_set_meta_integer (view->item, "delay", -1); g_object_notify (G_OBJECT (view), "uri"); @@ -4027,12 +4027,9 @@ midori_view_set_uri (MidoriView* view, gboolean midori_view_is_blank (MidoriView* view) { - const gchar* uri; - g_return_val_if_fail (MIDORI_IS_VIEW (view), TRUE); - uri = midori_view_get_display_uri (view); - return uri[0] == '\0' || g_str_has_prefix (uri, "about:"); + return midori_uri_is_blank (midori_view_get_display_uri (view)); } /** diff --git a/midori/midori.h b/midori/midori.h index 775eee08..f4e7a953 100644 --- a/midori/midori.h +++ b/midori/midori.h @@ -25,6 +25,7 @@ #include "midori-viewable.h" #include "midori-websettings.h" #include "midori-platform.h" +#include /* Vala API */ /* For convenience, include localization header */ #include diff --git a/midori/sokoke.c b/midori/sokoke.c index 5aae9cab..d8a47db6 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2007-2009 Christian Dywan + Copyright (C) 2007-2011 Christian Dywan Copyright (C) 2009 Dale Whittaker Copyright (C) 2009 Alexander Butenko @@ -18,6 +18,7 @@ #endif #include "midori-stock.h" +#include "midori-core.h" #if HAVE_UNISTD_H #include @@ -570,124 +571,6 @@ sokoke_spawn_app (const gchar* uri, g_free (command); } -/** - * sokoke_hostname_from_uri: - * @uri: an URI string - * @path: location of a string, or %NULL - * - * Returns the hostname of the specified URI. - * - * If there is a path, it is stored in @path. - * - * Return value: a newly allocated hostname - **/ -gchar* -sokoke_hostname_from_uri (const gchar* uri, - gchar** path) -{ - gchar* hostname; - - if ((hostname = strchr (uri, '/'))) - { - gchar* pathname; - if (hostname[1] == '/') - hostname += 2; - if ((pathname = strchr (hostname, '/'))) - { - if (path != NULL) - *path = pathname; - return g_strndup (hostname, pathname - hostname); - } - else - return g_strdup (hostname); - } - - return g_strdup (uri); -} - -/** - * sokoke_uri_to_ascii: - * @uri: an URI string - * - * The specified URI is parsed and the hostname - * part of it is encoded if it is not ASCII. - * - * If no IDN support is available at compile time, - * the URI will be returned unaltered. - * - * Return value: a newly allocated URI - **/ -gchar* -sokoke_uri_to_ascii (const gchar* uri) -{ - gchar* proto = NULL; - gchar* path = NULL; - gchar* hostname; - gchar* encoded; - - if (strchr (uri, '/') && (proto = strchr (uri, ':'))) - { - gulong offset; - gchar* buffer; - - offset = g_utf8_pointer_to_offset (uri, proto); - buffer = g_malloc0 (offset + 1); - g_utf8_strncpy (buffer, uri, offset); - proto = buffer; - } - - hostname = sokoke_hostname_from_uri (uri, &path); - encoded = g_hostname_to_ascii (hostname); - - if (encoded) - { - gchar* res = g_strconcat (proto ? proto : "", proto ? "://" : "", - encoded, path, NULL); - g_free (encoded); - return res; - } - g_free (hostname); - return g_strdup (uri); -} - -static gchar* -sokoke_idn_to_punycode (gchar* uri) -{ - return uri; -} - -/** - * sokoke_search_uri: - * @uri: a search URI with or without %s - * @keywords: keywords - * - * Takes a search engine URI and inserts the specified - * keywords. The @keywords are percent encoded. If the - * search URI contains a %s they keywords are inserted - * in that place, otherwise appended to the URI. - * - * Return value: a newly allocated search URI - **/ -gchar* sokoke_search_uri (const gchar* uri, - const gchar* keywords) -{ - gchar* escaped; - gchar* search; - - g_return_val_if_fail (keywords != NULL, NULL); - - if (!uri) - return g_strdup (keywords); - - escaped = g_uri_escape_string (keywords, ":/", TRUE); - if (strstr (uri, "%s")) - search = g_strdup_printf (uri, escaped); - else - search = g_strconcat (uri, escaped, NULL); - g_free (escaped); - return search; -} - static void sokoke_resolve_hostname_cb (SoupAddress *address, guint status, @@ -763,13 +646,6 @@ sokoke_magic_uri (const gchar* uri) g_return_val_if_fail (uri, NULL); - /* Just return if it's a javascript: or mailto: uri */ - if (!strncmp (uri, "javascript:", 11) - || !strncmp (uri, "mailto:", 7) - || sokoke_external_uri (uri) - || !strncmp (uri, "data:", 5) - || !strncmp (uri, "about:", 6)) - return g_strdup (uri); /* Add file:// if we have a local path */ if (g_path_is_absolute (uri)) return g_strconcat ("file://", uri, NULL); @@ -800,12 +676,9 @@ sokoke_magic_uri (const gchar* uri) g_free (longitude); return geo; } - /* Do we have a protocol? */ - if (g_strstr_len (uri, 8, "://")) - return sokoke_idn_to_punycode (g_strdup (uri)); - - /* Do we have an IP address? */ - if (g_ascii_isdigit (uri[0]) && g_strstr_len (uri, 4, ".")) + if (midori_uri_is_location (uri) || sokoke_external_uri (uri)) + return g_strdup (uri); + if (midori_uri_is_ip_address (uri)) return g_strconcat ("http://", uri, NULL); search = NULL; if (!strchr (uri, ' ') && @@ -833,75 +706,6 @@ sokoke_magic_uri (const gchar* uri) return NULL; } -/** - * sokoke_uri_unescape_string: - * @uri: an URI string - * - * Unescape @uri if needed, and pass through '+' and '%20'. - * - * Return value: a newly allocated URI - **/ -gchar* -sokoke_uri_unescape_string (const gchar* uri) -{ - if (strchr (uri,'%') || strchr (uri, ' ')) - { - /* Preserve %20 for pasting URLs into other windows */ - gchar* unescaped = g_uri_unescape_string (uri, "+"); - if (!unescaped) - return g_strdup (uri); - gchar* spaced = sokoke_replace_variables (unescaped, " ", "%20", NULL); - g_free (unescaped); - return spaced; - } - - return g_strdup (uri); -} - -/** - * sokoke_format_uri_for_display: - * @uri: an URI string - * - * Formats an URI for display, for instance by converting - * percent encoded characters and by decoding punycode. - * - * Return value: a newly allocated URI - **/ -gchar* -sokoke_format_uri_for_display (const gchar* uri) -{ - if (uri && g_str_has_prefix (uri, "http://")) - { - gchar* unescaped = sokoke_uri_unescape_string (uri); - gchar* path = NULL; - gchar* hostname; - gchar* decoded; - - if (!unescaped) - return g_strdup (uri); - else if (!g_utf8_validate (unescaped, -1, NULL)) - { - g_free (unescaped); - return g_strdup (uri); - } - - hostname = sokoke_hostname_from_uri (unescaped, &path); - decoded = g_hostname_to_unicode (hostname); - - if (decoded) - { - gchar* result = g_strconcat ("http://", decoded, path, NULL); - g_free (unescaped); - g_free (decoded); - g_free (hostname); - return result; - } - g_free (hostname); - return unescaped; - } - return g_strdup (uri); -} - void sokoke_combo_box_add_strings (GtkComboBox* combobox, const gchar* label_first, ...) diff --git a/midori/sokoke.h b/midori/sokoke.h index a7ddf8aa..91ec24c1 100644 --- a/midori/sokoke.h +++ b/midori/sokoke.h @@ -49,28 +49,12 @@ void sokoke_spawn_app (const gchar* uri, gboolean inherit_config); -gchar* sokoke_search_uri (const gchar* uri, - const gchar* keywords); - -gchar* -sokoke_hostname_from_uri (const gchar* uri, - gchar** path); - -gchar* -sokoke_uri_to_ascii (const gchar* uri); - gboolean sokoke_external_uri (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); - void sokoke_combo_box_add_strings (GtkComboBox* combobox, const gchar* label_first, diff --git a/panels/midori-extensions.c b/panels/midori-extensions.c index 133b982e..83164b36 100644 --- a/panels/midori-extensions.c +++ b/panels/midori-extensions.c @@ -15,8 +15,7 @@ #include "midori-extension.h" #include "midori-stock.h" #include "midori-viewable.h" - -#include "midori-extensions-column.c" +#include "midori-core.h" #include "sokoke.h" #include diff --git a/tests/magic-uri.c b/tests/magic-uri.c index 81ff023a..328034c0 100644 --- a/tests/magic-uri.c +++ b/tests/magic-uri.c @@ -15,6 +15,7 @@ #endif #include "sokoke.h" +#include #define SM "http://www.searchmash.com/search/" @@ -76,7 +77,7 @@ test_input (const gchar* input, } g_strfreev (parts); - uri = keywords ? sokoke_search_uri (search_uri, keywords) : NULL; + uri = keywords ? midori_uri_for_search (search_uri, keywords) : NULL; g_free (keywords); } @@ -134,7 +135,7 @@ magic_uri_idn (void) for (i = 0; i < G_N_ELEMENTS (items); i++) { - gchar* result = sokoke_uri_to_ascii (items[i].before); + gchar* result = midori_uri_to_ascii (items[i].before); const gchar* after = items[i].after ? items[i].after : items[i].before; sokoke_assert_str_equal (items[i].before, result, after); g_free (result); @@ -236,7 +237,7 @@ magic_uri_format (void) for (i = 0; i < G_N_ELEMENTS (items); i++) { - gchar* result = sokoke_format_uri_for_display (items[i].before); + gchar* result = midori_uri_format_for_display (items[i].before); const gchar* after = items[i].after ? items[i].after : items[i].before; sokoke_assert_str_equal (items[i].before, result, after); g_free (result);