Make Midori.URI.get_fingerprint more legible

This commit is contained in:
Paweł Forysiuk 2012-08-12 16:53:43 +02:00 committed by Christian Dywan
parent 21e7464226
commit 870ecca738
2 changed files with 15 additions and 9 deletions

View File

@ -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;

View File

@ -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