From 3367f8c2e08bf998efc84050e39d5a9fbdffb5dd Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sun, 14 Aug 2016 15:11:04 +0100 Subject: Expansions: new ${escape8bit:} operator. Bug 1863 --- src/src/expand.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/src/expand.c b/src/src/expand.c index c13284d8e..fd55436a2 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -207,6 +207,7 @@ static uschar *op_table_main[] = { US"base64d", US"domain", US"escape", + US"escape8bit", US"eval", US"eval10", US"expand", @@ -252,6 +253,7 @@ enum { EOP_BASE64D, EOP_DOMAIN, EOP_ESCAPE, + EOP_ESCAPE8BIT, EOP_EVAL, EOP_EVAL10, EOP_EXPAND, @@ -7109,11 +7111,23 @@ while (*s != 0) case EOP_ESCAPE: { - const uschar *t = string_printing(sub); + const uschar * t = string_printing(sub); yield = string_cat(yield, &size, &ptr, t); continue; } + case EOP_ESCAPE8BIT: + { + const uschar * s = sub; + uschar c; + + for (s = sub; c = *s; s++) + yield = c < 127 && c != '\\' + ? string_catn(yield, &size, &ptr, s, 1) + : string_catn(yield, &size, &ptr, string_sprintf("\\%03o", c), 4); + continue; + } + /* Handle numeric expression evaluation */ case EOP_EVAL: -- cgit v1.2.3