From aeb71dd7b4ec2e88b999a033e777a445dff714ef Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Tue, 9 Dec 2008 00:02:38 +0100 Subject: [PATCH] Add support for javascript: bookmarklets --- midori/midori-view.c | 4 ++++ midori/sokoke.c | 3 +++ tests/magic-uri.c | 1 + 3 files changed, 8 insertions(+) diff --git a/midori/midori-view.c b/midori/midori-view.c index 1e5bbbd3..8a89b137 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -1551,6 +1551,10 @@ midori_view_set_uri (MidoriView* view, return; } } + else if (g_str_has_prefix (uri, "javascript:")) + { + midori_view_execute_script (view, &uri[11], NULL); + } else { katze_assign (view->uri, g_strdup (uri)); diff --git a/midori/sokoke.c b/midori/sokoke.c index 970b54bd..305261ce 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -97,6 +97,9 @@ sokoke_magic_uri (const gchar* uri, g_return_val_if_fail (!search_engines || katze_array_is_a (search_engines, KATZE_TYPE_ITEM), NULL); + /* Just return if it's a javascript: uri */ + if (g_str_has_prefix (uri, "javascript:")) + return g_strdup (uri); /* Add file:// if we have a local path */ if (g_path_is_absolute (uri)) return g_strconcat ("file://", uri, NULL); diff --git a/tests/magic-uri.c b/tests/magic-uri.c index 18bfa86e..3a8dbafa 100644 --- a/tests/magic-uri.c +++ b/tests/magic-uri.c @@ -83,6 +83,7 @@ main (int argc, test_input ("verbose de.po", NULL); test_input ("g de.po verbose", NULL); test_input ("sm de.po verbose", SM "de.po verbose"); + test_input ("javascript:alert(1)", "javascript:alert(1)"); return 0; } -- 2.39.5