[Xfce4-commits] <midori:master> Make Midori.URI.get_fingerprint more legible

Christian Dywan noreply at xfce.org
Thu Aug 16 00:22:02 CEST 2012


Updating branch refs/heads/master
         to 870ecca738d969d93ccfc3ab78865a596327022f (commit)
       from 21e74642265d8e378149715f59c9b96c29ce7761 (commit)

commit 870ecca738d969d93ccfc3ab78865a596327022f
Author: Paweł Forysiuk <tuxator at o2.pl>
Date:   Sun Aug 12 16:53:43 2012 +0200

    Make Midori.URI.get_fingerprint more legible

 katze/midori-uri.vala |   22 +++++++++++++---------
 tests/magic-uri.c     |    2 ++
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/katze/midori-uri.vala b/katze/midori-uri.vala
index 4dad32c..c823a48 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 b80bf15..53bee47 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


More information about the Xfce4-commits mailing list