From: Christian Dywan Date: Tue, 18 Sep 2012 19:25:59 +0000 (+0200) Subject: Remove is_email API and needless hard-coding of mailto: X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e39d05a172b2b5ae885c5538ce18b18c10c13ff;p=midori Remove is_email API and needless hard-coding of mailto: --- diff --git a/katze/midori-uri.vala b/katze/midori-uri.vala index adefff83..05ebceab 100644 --- a/katze/midori-uri.vala +++ b/katze/midori-uri.vala @@ -114,12 +114,7 @@ namespace Midori { || (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 diff --git a/midori/midori-view.c b/midori/midori-view.c index a2337f4e..b3b6634b 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -959,7 +959,7 @@ midori_view_web_view_navigation_decision_cb (WebKitWebView* web_view g_free (new_uri); return TRUE; } - else if (g_str_has_prefix (uri, "mailto:") || sokoke_external_uri (uri)) + else if (sokoke_external_uri (uri)) { if (sokoke_show_uri (gtk_widget_get_screen (GTK_WIDGET (web_view)), uri, GDK_CURRENT_TIME, NULL)) @@ -1784,7 +1784,7 @@ static gboolean midori_view_always_same_tab (const gchar* uri) { /* No opening in tab, window or app for Javascript or mailto links */ - return g_str_has_prefix (uri, "javascript:") || midori_uri_is_email (uri); + return g_str_has_prefix (uri, "javascript:") || g_str_has_prefix (uri, "mailto:"); } static void @@ -2831,7 +2831,10 @@ midori_view_populate_popup (MidoriView* view, g_strstrip (view->selected_text); if (midori_uri_is_valid (view->selected_text)) { - if (midori_uri_is_email (view->selected_text)) + /* :// and @ together would mean login credentials */ + if (g_str_has_prefix (view->selected_text, "mailto:") + || (strchr (view->selected_text, '@') != NULL + && strstr (view->selected_text, "://") == NULL)) { gchar* text = g_strdup_printf (_("Send a message to %s"), view->selected_text); menuitem = midori_view_insert_menu_item (menu_shell, -1, @@ -4466,7 +4469,7 @@ midori_view_set_uri (MidoriView* view, g_free (exception); } } - else if (g_str_has_prefix (uri, "mailto:") || sokoke_external_uri (uri)) + else if (sokoke_external_uri (uri)) { sokoke_show_uri (NULL, uri, GDK_CURRENT_TIME, NULL); } diff --git a/tests/magic-uri.c b/tests/magic-uri.c index f036feab..be9a1999 100644 --- a/tests/magic-uri.c +++ b/tests/magic-uri.c @@ -212,7 +212,6 @@ static void magic_uri_pseudo (void) { test_input ("javascript:alert(1)", "javascript:alert(1)"); - test_input ("mailto:christian@twotoasts.de", "mailto:christian@twotoasts.de"); test_input ("data:text/html;charset=utf-8,TestTest", "data:text/html;charset=utf-8,TestTest"); }