From d27407c824b63bd0b9c78479453c3ce4799afac8 Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Thu, 26 Jun 2008 20:03:18 +0100 Subject: [PATCH 1/1] 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 --- keyindex.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) 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; -- 2.39.5