From: Jonathan McDowell Date: Thu, 26 Jun 2008 19:03:18 +0000 (+0100) Subject: Escape colons and similar in MRHKP output X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/commitdiff_plain/d27407c824b63bd0b9c78479453c3ce4799afac8?ds=inline Escape colons and similar in MRHKP output : is used as a separator in MRHKP output, so we need to escape it. We also need to escape % for similar reasons, so do so. Closes Debian bug #487284 --- diff --git a/keyindex.c b/keyindex.c index c708aa4..fead60b 100644 --- a/keyindex.c +++ b/keyindex.c @@ -1,9 +1,7 @@ /* * keyindex.c - Routines to list an OpenPGP key. * - * Jonathan McDowell - * - * Copyright 2002-2005 Project Purple + * Copyright 2002-2008 Jonathan McDowell */ #include @@ -320,6 +318,7 @@ int mrkey_index(struct openpgp_publickey *keys) int i = 0; size_t fplength = 0; unsigned char fp[20]; + int c; while (keys != NULL) { created_time = (keys->publickey->data[1] << 24) + @@ -363,9 +362,20 @@ int mrkey_index(struct openpgp_publickey *keys) curuid = curuid->next) { if (curuid->packet->tag == 13) { - printf("uid:%.*s\n", - (int) curuid->packet->length, - curuid->packet->data); + printf("uid:"); + for (i = 0; i < (int) curuid->packet->length; + i++) { + c = curuid->packet->data[i]; + if (c == '%') { + putchar('%'); + putchar(c); + } else if (c == ':' || c > 127) { + printf("%%%X", c); + } else { + putchar(c); + } + } + printf("\n"); } } keys = keys->next;