]> granicus.if.org Git - apache/commitdiff
Merge r1457437, r1457520 from trunk:
authorJim Jagielski <jim@apache.org>
Mon, 15 Apr 2013 12:36:23 +0000 (12:36 +0000)
committerJim Jagielski <jim@apache.org>
Mon, 15 Apr 2013 12:36:23 +0000 (12:36 +0000)
Expression parser: Add the ability to base64 encode and base64 decode
strings within the parser.

Remove the comment, this is done.

Submitted by: minfrin
Reviewed/backported by: jim

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1467969 13f79535-47bb-0310-9956-ffa450edef68

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

diff --git a/STATUS b/STATUS
index 21c28219a1d1355d6b5ac2b07b2f099c1fb4838b..11da99eb528b4a049cbf7bc487fb20dbdf2bef70 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -90,13 +90,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  * ap_expr: Expression parser: Add the ability to base64 encode and base64
-    decode strings within the parser.
-    trunk patch: http://svn.apache.org/r1457437
-                 http://svn.apache.org/r1457520
-    2.4.x patch: trunk patch applies.
-    +1: minfrin, druggeri, rjung
-
    * util_filter: Add in ap_remove_input|output_filter_byhandle()
     trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1458456
     2.4.x patch: trunk patch works modulo ap_mmn.h
index c75c967ba13b517083999d101fc331264e3b038e..13b5cee89ab5d37ccf80b54caf01d5120391a5d4 100644 (file)
@@ -459,6 +459,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 b350cfc7716d9e823aadff9bf04775f7abf564ba..46bd4b6e85363d13b03556559776fcd6b559e8f9 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)
@@ -1575,9 +1587,10 @@ 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 ? */
 
 static const struct expr_provider_single unary_op_providers[] = {
     { op_nz,        "n", NULL,             0 },