aboutsummaryrefslogtreecommitdiffstats
path: root/g10/misc.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2005-05-24 12:39:42 +0000
committerWerner Koch <[email protected]>2005-05-24 12:39:42 +0000
commitd0f5655d193de656672490f9789c3abd5341999a (patch)
tree23bd6a26c0984b19445c39ab575b010f094ddea1 /g10/misc.c
parent(add_notation_data): Check number of at-signs. (diff)
downloadgnupg-d0f5655d193de656672490f9789c3abd5341999a.tar.gz
gnupg-d0f5655d193de656672490f9789c3abd5341999a.zip
* passphrase.c (ask_passphrase): Unescape the description string.
* cardglue.c (unescape_status_string): Removed. Changed all caller to use ... * misc.c (unescape_percent_string): New.
Diffstat (limited to '')
-rw-r--r--g10/misc.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/g10/misc.c b/g10/misc.c
index 6e3dbce0b..175590ce2 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -1029,6 +1029,41 @@ parse_options(char *str,unsigned int *options,
}
+/* Return a new malloced string by unescaping the string S. Escaping
+ is percent escaping and '+'/space mapping. A binary nul will
+ silently be replaced by a 0xFF. */
+char *
+unescape_percent_string (const unsigned char *s)
+{
+ char *buffer, *d;
+
+ buffer = d = xmalloc (strlen (s)+1);
+ while (*s)
+ {
+ if (*s == '%' && s[1] && s[2])
+ {
+ s++;
+ *d = xtoi_2 (s);
+ if (!*d)
+ *d = '\xff';
+ d++;
+ s += 2;
+ }
+ else if (*s == '+')
+ {
+ *d++ = ' ';
+ s++;
+ }
+ else
+ *d++ = *s++;
+ }
+ *d = 0;
+ return buffer;
+}
+
+
+
+
/* This is a helper function to load a Windows function from either of
one DLLs. */
#ifdef HAVE_W32_SYSTEM