From: Paweł Forysiuk Date: Sun, 12 Aug 2012 14:53:43 +0000 (+0200) Subject: Make Midori.URI.get_fingerprint more legible X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=870ecca738d969d93ccfc3ab78865a596327022f;p=midori Make Midori.URI.get_fingerprint more legible --- diff --git a/katze/midori-uri.vala b/katze/midori-uri.vala index 4dad32c1..c823a48f 100644 --- a/katze/midori-uri.vala +++ b/katze/midori-uri.vala @@ -146,21 +146,25 @@ namespace Midori { out string checksum, out string label) { /* http://foo.bar/baz/spam.eggs#!algo!123456 */ + unowned string display = null; + GLib.ChecksumType type = (GLib.ChecksumType)int.MAX; + unowned string delimiter = "#!md5!"; - unowned string display = _("MD5-Checksum:"); - GLib.ChecksumType type = GLib.ChecksumType.MD5; unowned string? fragment = uri.str (delimiter); - if (fragment == null) { - delimiter = "#!sha1!"; + if (fragment != null) { + display = _("MD5-Checksum:"); + type = GLib.ChecksumType.MD5; + } + + delimiter = "#!sha1!"; + fragment = uri.str (delimiter); + if (fragment != null) { display = _("SHA1-Checksum:"); type = GLib.ChecksumType.SHA1; - fragment = uri.str (delimiter); - } - if (fragment == null) { - type = (GLib.ChecksumType)int.MAX; - display = null; } + /* No SHA256: no known usage and no need for strong encryption */ + if (&checksum != null) checksum = fragment != null ? fragment.offset (delimiter.length) : null; diff --git a/tests/magic-uri.c b/tests/magic-uri.c index b80bf153..53bee470 100644 --- a/tests/magic-uri.c +++ b/tests/magic-uri.c @@ -249,6 +249,8 @@ magic_uri_fingerprint (void) g_assert_cmpint (midori_uri_get_fingerprint (uri, NULL, NULL), ==, G_MAXINT); uri = "http://midori-0.4.1.tar.bz2#abcdefg"; g_assert_cmpint (midori_uri_get_fingerprint (uri, NULL, NULL), ==, G_MAXINT); + uri = "http://midori-0.4.1.tar.bz2"; + g_assert_cmpint (midori_uri_get_fingerprint (uri, NULL, NULL), ==, G_MAXINT); } static void