aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--common/stringhelp.c10
-rw-r--r--tools/gpgconf-comp.c7
2 files changed, 16 insertions, 1 deletions
diff --git a/common/stringhelp.c b/common/stringhelp.c
index 341dd525b..bea146647 100644
--- a/common/stringhelp.c
+++ b/common/stringhelp.c
@@ -1052,7 +1052,8 @@ do_percent_escape (const char *str, const char *extra, int die)
return NULL;
for (i=j=0; str[i]; i++)
- if (str[i] == ':' || str[i] == '%' || (extra && strchr (extra, str[i])))
+ if (str[i] == ':' || str[i] == '%' || str[i] == '\n'
+ || (extra && strchr (extra, str[i])))
j++;
if (die)
ptr = xmalloc (i + 2 * j + 1);
@@ -1077,6 +1078,13 @@ do_percent_escape (const char *str, const char *extra, int die)
ptr[i++] = '2';
ptr[i++] = '5';
}
+ else if (*str == '\n')
+ {
+ /* The newline is problematic in a line-based format. */
+ ptr[i++] = '%';
+ ptr[i++] = '0';
+ ptr[i++] = 'a';
+ }
else if (extra && strchr (extra, *str))
{
ptr[i++] = '%';
diff --git a/tools/gpgconf-comp.c b/tools/gpgconf-comp.c
index d53947e7f..0c939e5e0 100644
--- a/tools/gpgconf-comp.c
+++ b/tools/gpgconf-comp.c
@@ -1491,6 +1491,13 @@ gc_percent_escape (const char *src)
*(dst++) = '2';
*(dst++) = 'c';
}
+ else if (*src == '\n')
+ {
+ /* The newline is problematic in a line-based format. */
+ *(dst++) = '%';
+ *(dst++) = '0';
+ *(dst++) = 'a';
+ }
else
*(dst++) = *(src);
src++;