Merge lp:~gue5t/midori/fix-bug1183979 into lp:midori

Proposed by gue5t gue5t
Status: Merged
Approved by: Paweł Forysiuk
Approved revision: 6176
Merged at revision: 6174
Proposed branch: lp:~gue5t/midori/fix-bug1183979
Merge into: lp:midori
Diff against target: 82 lines (+42/-5)
2 files modified
midori/sokoke.c (+7/-5)
tests/magic-uri.c (+35/-0)
To merge this branch: bzr merge lp:~gue5t/midori/fix-bug1183979
Reviewer Review Type Date Requested Status
Paweł Forysiuk Approve
Review via email: mp+165802@code.launchpad.net

This proposal supersedes a proposal from 2013-05-27.

Commit message

Compare uri schemes case-insensitively.

To post a comment you must log in.
Revision history for this message
Paweł Forysiuk (tuxator) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'midori/sokoke.c'
2--- midori/sokoke.c 2013-05-19 09:33:02 +0000
3+++ midori/sokoke.c 2013-05-27 00:36:25 +0000
4@@ -136,7 +136,7 @@
5 gtk_widget_destroy (dialog);
6 }
7
8-static GAppInfo*
9+GAppInfo*
10 sokoke_default_for_uri (const gchar* uri,
11 gchar** scheme_ptr)
12 {
13@@ -474,10 +474,12 @@
14 {
15 GAppInfo* info;
16
17- if (!uri || !strncmp (uri, "http", 4)
18- || !strncmp (uri, "file", 4)
19- || !strncmp (uri, "geo", 3)
20- || !strncmp (uri, "about:", 6))
21+ /* URI schemes are case-insensitive, followed by ':' - rfc3986 */
22+ if (!uri || !strncasecmp (uri, "http:", 5)
23+ || !strncasecmp (uri, "https:", 6)
24+ || !strncasecmp (uri, "file:", 5)
25+ || !strncasecmp (uri, "geo:", 4)
26+ || !strncasecmp (uri, "about:", 6))
27 return FALSE;
28
29 info = sokoke_default_for_uri (uri, NULL);
30
31=== modified file 'tests/magic-uri.c'
32--- tests/magic-uri.c 2013-03-12 17:09:26 +0000
33+++ tests/magic-uri.c 2013-05-27 00:36:25 +0000
34@@ -386,6 +386,40 @@
35 }
36 }
37
38+GAppInfo* sokoke_default_for_uri (const gchar* uri, gchar** scheme_ptr);
39+
40+static gboolean uri_has_default (const gchar* uri)
41+{
42+ GAppInfo* info = sokoke_default_for_uri (uri, NULL);
43+ if (info)
44+ g_object_unref (info);
45+ return info != NULL;
46+}
47+
48+static void
49+magic_uri_protocols (void)
50+{
51+ g_assert (!sokoke_external_uri (NULL));
52+ g_assert (!sokoke_external_uri (""));
53+
54+ g_assert (!sokoke_external_uri ("http://google.com"));
55+ g_assert (!sokoke_external_uri ("HTTP://google.com"));
56+ g_assert (!sokoke_external_uri ("Http://google.com"));
57+ g_assert (!sokoke_external_uri ("https://google.com"));
58+ g_assert (!sokoke_external_uri ("httPS://google.com"));
59+ g_assert (!sokoke_external_uri ("file:///home/"));
60+ g_assert (!sokoke_external_uri ("geo:100,3000"));
61+ g_assert (!sokoke_external_uri ("about:blank"));
62+
63+ g_assert (!sokoke_external_uri ("https://"));
64+ g_assert (!sokoke_external_uri ("http://"));
65+ g_assert (!sokoke_external_uri ("http:/"));
66+ g_assert (!sokoke_external_uri ("http"));
67+ g_assert (sokoke_external_uri ("ftp://ftphost.org") == uri_has_default ("ftp://ftphost.org"));
68+ g_assert (sokoke_external_uri ("geometry:bar") == uri_has_default ("geometry:bar"));
69+ g_assert (sokoke_external_uri ("httparty:woo") == uri_has_default ("httparty:woo"));
70+}
71+
72 int
73 main (int argc,
74 char** argv)
75@@ -404,6 +438,7 @@
76 g_test_add_func ("/magic-uri/prefix", magic_uri_prefix);
77 g_test_add_func ("/magic-uri/prefetch", magic_uri_prefetch);
78 g_test_add_func ("/magic-uri/commands", magic_uri_commands);
79+ g_test_add_func ("/magic-uri/protocols", magic_uri_protocols);
80
81 return g_test_run ();
82 }

Subscribers

People subscribed via source and target branches

to all changes: