List for cgit developers and users
 help / color / mirror / Atom feed
From: john at keeping.me.uk (John Keeping)
Subject: [PATCH 1/1] enable cgit to show gravatar for author, committer and tagger
Date: Wed, 27 Nov 2013 16:37:24 +0000	[thread overview]
Message-ID: <20131127163724.GF15033@serenity.lan> (raw)
In-Reply-To: <1385565437-15752-1-git-send-email-mail@eworm.de>

On Wed, Nov 27, 2013 at 04:17:17PM +0100, Christian Hesse wrote:
> diff --git a/parsing.c b/parsing.c
> index 658621d..a8005f6 100644
> --- a/parsing.c
> +++ b/parsing.c
> @@ -8,6 +8,9 @@
>  
>  #include "cgit.h"
>  
> +/* we need md5 hashing algorithm to calculate Gravatar URL */
> +#include <openssl/md5.h>

We don't currently depend on OpenSSL, except via Git which can use
alternative SHA-1 implementations.

At the very least Debian will not distribute GPL'd packages
linked against OpenSSL [1].

[1] http://lintian.debian.org/tags/possible-gpl-code-linked-with-openssl.html

> +char * cgit_get_gravatar(const char * email) {
> +    	int n, length;
> +	MD5_CTX c;
> +	unsigned char digest[16];
> +	char hex[33];
> +	char * gravatar = malloc(67);
> +
> +	/* skip brackets! */
> +	email++;
> +	length = strlen(email) - 1;
> +
> +	MD5_Init(&c);
> +
> +	while (length > 0) {
> +		if (length > 512)
> +			MD5_Update(&c, email, 512);
> +		else
> +			MD5_Update(&c, email, length);
> +		length -= 512;
> +		email += 512;
> +	}
> +
> +	MD5_Final(digest, &c);

Would it be possible to extract everything from MD5_Init to MD5_Final to
a function that just computes the MD5 of a string?  That should make it
easier to add alternative implementations.

> +	for (n = 0; n < 16; ++n)
> +		snprintf(&(hex[n*2]), 16*2, "%02x", (unsigned int)digest[n]);
> +
> +	sprintf(gravatar, "http://www.gravatar.com/avatar/%s?s=", hex);
> +
> +	return gravatar;
> +}


  parent reply	other threads:[~2013-11-27 16:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-27 15:17 mail
2013-11-27 16:17 ` list
2013-11-27 16:37 ` john [this message]
2013-11-27 20:51   ` list
2013-11-27 21:00     ` john
2013-11-27 16:46 ` lekensteyn
2013-11-27 20:59   ` list
2013-11-27 21:14     ` mail
2013-11-27 22:11       ` lekensteyn
2013-11-27 22:59         ` list
2013-11-27 23:00           ` mail
2014-01-08 15:12 [RESEND PATCH " Jason
2014-01-08 15:23 ` [PATCH " mail
2014-01-08 15:56   ` Jason
2014-01-09  8:52     ` mail
2014-01-09 15:13       ` Jason
2014-01-08 16:00   ` Jason
2014-01-09  9:13     ` mail

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131127163724.GF15033@serenity.lan \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).