From: lekensteyn at gmail.com (Peter Wu)
Subject: [PATCH 1/1] enable cgit to show gravatar for author, committer and tagger
Date: Wed, 27 Nov 2013 23:11:49 +0100 [thread overview]
Message-ID: <461884100.iMVHHtLi2p@al> (raw)
In-Reply-To: <1385586862-29756-1-git-send-email-mail@eworm.de>
On Wednesday 27 November 2013 22:14:22 Christian Hesse wrote:
> +char * cgit_get_gravatar(const char *email) {
> + unsigned char digest[16];
> + char hex[33], *lower, *tmp;
> + char *gravatar;
> +
> + gravatar = malloc(77);
I do not quite like this magic number, does anyone have problems with
creating a GRAVATAR_URL macro? 77 seems also small enough to throw on the
stack. (Btw, len("//www.gravatar.com/avatar/?s=16&d=retro") + 32 + 1
says that the length is 76 including nul byte).
> + /* duplicate to lower and skip brackets! */
> + lower = strdup(email + 1);
> + lower[strlen(lower) - 1] = '\0';
Ahh, I though it was off by one, but apparently you remove the brackets. OK.
> +
> + /* make the chars lower case */
> + for (tmp = lower; *tmp; ++tmp)
> + *tmp = tolower(*tmp);
> +
> + MD5((unsigned char *)lower, strlen(lower), digest);
> +
> + str_to_hex(hex, digest, 16);
> +
> + sprintf(gravatar, "//www.gravatar.com/avatar/%s?s=16&d=retro", hex);
It seems ugly to me to store the HTML-escaped URL here. What do you think of
using just "&" here and html_txt() when outputting the URL? Processing these
few chars and performing an extra write() should not hurt performance.
Regarding the GRAVATAR_URL macro mentioned earlier, if used that could
also be inserted here. A comment could then describe why this URL is used
(16x16 image using "awesome generated, 8-bit arcade-style pixelated faces"
as default, https://en.gravatar.com/site/implement/images/)
> + free(lower);
> +
> + return gravatar;
> +}
Regards,
Peter
next prev parent reply other threads:[~2013-11-27 22:11 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
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 [this message]
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=461884100.iMVHHtLi2p@al \
--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).