[exim-cvs] ${hexquote: expansion operator

Góra strony
Delete this message
Reply to this message
Autor: Exim Git Commits Mailing List
Data:  
Dla: exim-cvs
Temat: [exim-cvs] ${hexquote: expansion operator
Gitweb: http://git.exim.org/exim.git/commitdiff/c393f9312e022187f24bc9536e9d3ea426009ea0
Commit:     c393f9312e022187f24bc9536e9d3ea426009ea0
Parent:     da45993f49e890de3642db3f4c8bddbdb5302277
Author:     Tony Finch <dot@???>
AuthorDate: Fri Oct 12 14:52:28 2012 +0100
Committer:  Tony Finch <dot@???>
CommitDate: Thu May 23 18:44:04 2013 +0100


    ${hexquote: expansion operator


    This converts octets outside the range 0x21-0x7E (the ASCII
    graphic characters) to \xNN hex escapes.
---
 src/src/expand.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)


diff --git a/src/src/expand.c b/src/src/expand.c
index 391b943..1da2225 100644
--- a/src/src/expand.c
+++ b/src/src/expand.c
@@ -181,6 +181,7 @@ static uschar *op_table_main[] = {
   US"h",
   US"hash",
   US"hex2b64",
+  US"hexquote",
   US"l",
   US"lc",
   US"length",
@@ -216,6 +217,7 @@ enum {
   EOP_H,
   EOP_HASH,
   EOP_HEX2B64,
+  EOP_HEXQUOTE,
   EOP_L,
   EOP_LC,
   EOP_LENGTH,
@@ -5664,6 +5666,22 @@ while (*s != 0)
         continue;
         }


+      /* Convert octets outside 0x21..0x7E to \xXX form */
+
+      case EOP_HEXQUOTE:
+    {
+        uschar *t = sub - 1;
+        while (*(++t) != 0)
+          {
+          if (*t < 0x21 || 0x7E < *t)
+            yield = string_cat(yield, &size, &ptr,
+          string_sprintf("\\x%02x", *t), 4);
+      else
+        yield = string_cat(yield, &size, &ptr, t, 1);
+          }
+    continue;
+    }
+
       /* count the number of list elements */


       case EOP_LISTCOUNT: