]> granicus.if.org Git - apache/commitdiff
Expression parser: Add the ability to base64 encode and base64 decode
authorGraham Leggett <minfrin@apache.org>
Sun, 17 Mar 2013 12:49:27 +0000 (12:49 +0000)
committerGraham Leggett <minfrin@apache.org>
Sun, 17 Mar 2013 12:49:27 +0000 (12:49 +0000)
strings within the parser.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1457437 13f79535-47bb-0310-9956-ffa450edef68

docs/manual/expr.xml
server/util_expr_eval.c

index f537e852b3de59baf9b3045282a885d9a414b321..51bfbf3d4b8d2eec2249db482296065c986d1756 100644 (file)
@@ -472,6 +472,11 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
     <tr><td><code>unescape</code></td>
         <td>Unescape %hex encoded string, leaving encoded slashes alone;
             return empty string if %00 is found</td><td></td></tr>
+    <tr><td><code>base64</code></td>
+        <td>Encode the string using base64 encoding</td><td></td></tr>
+    <tr><td><code>unbase64</code></td>
+        <td>Decode base64 encoded string, return truncated string if 0x00 is
+            found</td><td></td></tr>
     <tr><td><code>file</code></td>
         <td>Read contents from a file</td><td>yes</td></tr>
     <tr><td><code>filesize</code></td>
index 56035dc84c240f32ca60c21e39f671ac4fbfe86b..4088fc42ae1417b7ca767104e027c123047a2140 100644 (file)
@@ -1019,6 +1019,18 @@ static const char *escape_func(ap_expr_eval_ctx_t *ctx, const void *data,
     return ap_escape_uri(ctx->p, arg);
 }
 
+static const char *base64_func(ap_expr_eval_ctx_t *ctx, const void *data,
+                               const char *arg)
+{
+    return ap_pbase64encode(ctx->p, (char *)arg);
+}
+
+static const char *unbase64_func(ap_expr_eval_ctx_t *ctx, const void *data,
+                               const char *arg)
+{
+    return ap_pbase64decode(ctx->p, arg);
+}
+
 #define MAX_FILE_SIZE 10*1024*1024
 static const char *file_func(ap_expr_eval_ctx_t *ctx, const void *data,
                              char *arg)
@@ -1598,6 +1610,8 @@ static const struct expr_provider_single string_func_providers[] = {
     { unescape_func,        "unescape",       NULL, 0 },
     { file_func,            "file",           NULL, 1 },
     { filesize_func,        "filesize",       NULL, 1 },
+    { base64_func,          "base64",         NULL, 0 },
+    { unbase64_func,        "unbase64",       NULL, 0 },
     { NULL, NULL, NULL}
 };
 /* XXX: base64 encode/decode ? */