diff options
-rw-r--r-- | src/src/functions.h | 1 | ||||
-rw-r--r-- | src/src/spool_in.c | 2 | ||||
-rw-r--r-- | src/src/spool_out.c | 2 | ||||
-rw-r--r-- | src/src/string.c | 69 |
4 files changed, 72 insertions, 2 deletions
diff --git a/src/src/functions.h b/src/src/functions.h index 9e8a9546f..f1af42ee5 100644 --- a/src/src/functions.h +++ b/src/src/functions.h @@ -331,6 +331,7 @@ extern uschar *string_nextinlist(uschar **, int *, uschar *, int); extern uschar *string_open_failed(int, const char *, ...) PRINTF_FUNCTION(2,3); extern uschar *string_printing2(uschar *, BOOL); extern uschar *string_split_message(uschar *); +extern uschar *string_unprinting(uschar *); extern BOOL string_vformat(uschar *, int, const char *, va_list); extern int strcmpic(const uschar *, const uschar *); extern int strncmpic(const uschar *, const uschar *, int); diff --git a/src/src/spool_in.c b/src/src/spool_in.c index 0e4bc413d..e0d7fcffe 100644 --- a/src/src/spool_in.c +++ b/src/src/spool_in.c @@ -548,7 +548,7 @@ for (;;) else if (Ustrncmp(p, "ls_cipher", 9) == 0) tls_cipher = string_copy(big_buffer + 12); else if (Ustrncmp(p, "ls_peerdn", 9) == 0) - tls_peerdn = string_copy(big_buffer + 12); + tls_peerdn = string_unprinting(string_copy(big_buffer + 12)); break; #endif diff --git a/src/src/spool_out.c b/src/src/spool_out.c index f84cda642..7b8229934 100644 --- a/src/src/spool_out.c +++ b/src/src/spool_out.c @@ -228,7 +228,7 @@ if (bmi_verdicts != NULL) fprintf(f, "-bmi_verdicts %s\n", bmi_verdicts); #ifdef SUPPORT_TLS if (tls_certificate_verified) fprintf(f, "-tls_certificate_verified\n"); if (tls_cipher != NULL) fprintf(f, "-tls_cipher %s\n", tls_cipher); -if (tls_peerdn != NULL) fprintf(f, "-tls_peerdn %s\n", tls_peerdn); +if (tls_peerdn != NULL) fprintf(f, "-tls_peerdn %s\n", string_printing(tls_peerdn)); #endif /* To complete the envelope, write out the tree of non-recipients, followed by diff --git a/src/src/string.c b/src/src/string.c index 1c1f2dd83..ece200bcc 100644 --- a/src/src/string.c +++ b/src/src/string.c @@ -242,9 +242,12 @@ if (isdigit(ch) && ch != '8' && ch != '9') } else switch(ch) { + case 'b': ch = '\b'; break; + case 'f': ch = '\f'; break; case 'n': ch = '\n'; break; case 'r': ch = '\r'; break; case 't': ch = '\t'; break; + case 'v': ch = '\v'; break; case 'x': ch = 0; if (isxdigit(p[1])) @@ -329,6 +332,72 @@ while (*t != 0) *tt = 0; return ss; } + +/************************************************* +* Undo printing escapes in string * +*************************************************/ + +/* This function is the reverse of string_printing2. It searches for +backslash characters and if any are found, it makes a new copy of the +string with escape sequences parsed. Otherwise it returns the original +string. + +Arguments: + s the input string + +Returns: string with printing escapes parsed back +*/ + +uschar * +string_unprinting(uschar *s) +{ +uschar *p, *q, *r, *ss; +int len, off; + +p = Ustrchr(s, '\\'); +if (!p) return s; + +len = Ustrlen(s) + 1; +ss = store_get(len); + +q = ss; +off = p - s; +if (off) + { + memcpy(q, s, off); + q += off; + } + +while (*p) + { + if (*p == '\\') + { + *q = string_interpret_escape(&p); + } + else + { + r = Ustrchr(p, '\\'); + if (!r) + { + off = Ustrlen(p); + memcpy(q, p, off); + p += off; + q += off; + break; + } + else + { + off = r - p; + memcpy(q, p, off); + q += off; + p = r; + } + } + } +*q = '\0'; + +return ss; +} #endif /* COMPILE_UTILITY */ |