]> granicus.if.org Git - apache/commitdiff
Merge r1458004 from trunk:
authorJim Jagielski <jim@apache.org>
Mon, 22 Apr 2013 14:08:42 +0000 (14:08 +0000)
committerJim Jagielski <jim@apache.org>
Mon, 22 Apr 2013 14:08:42 +0000 (14:08 +0000)
add md5 function, too

Submitted by: sf
Reviewed/backported by: jim

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

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

diff --git a/STATUS b/STATUS
index 12bc2cb209c26bdaa164abc85f8c03b9ebdb959f..1e694815bf20e18b3fffe0f38b5853210980404e 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -90,12 +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 apply a md5 hash to
-     strings within the parser.
-     trunk patch: http://svn.apache.org/r1458004
-     2.4.x patch: trunk patch applies if previous proposals for ap_expr get applied.
-     +1: rjung, minfrin, sf
-
     * various: Use %pm available since apr 1.3 instead of an extra call to apr_strerror
       trunk patches: https://svn.apache.org/r1463056
       2.4.x patch: trunk patch works (with offset)
index 12b8df1e4fb743a81d2f9ad106b88d4a8bf98f2c..fead54319ffeccea3ff6fb02576474bd86b23e97 100644 (file)
@@ -464,6 +464,9 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
     <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>md5</code></td>
+        <td>Hash the string using MD5, then encode the hash with hexadecimal
+            encoding</td><td></td></tr>
     <tr><td><code>sha1</code></td>
         <td>Hash the string using SHA1, then encode the hash with hexadecimal
             encoding</td><td></td></tr>
index 92146a23c386baa70cd12ef3451132a43a1cc252..e3adf88ae1aabba218fe5131923adb637eb8bd99 100644 (file)
@@ -25,6 +25,7 @@
 #include "http_request.h"
 #include "ap_provider.h"
 #include "util_expr_private.h"
+#include "util_md5.h"
 
 #include "apr_lib.h"
 #include "apr_fnmatch.h"
@@ -1051,6 +1052,13 @@ static const char *sha1_func(ap_expr_eval_ctx_t *ctx, const void *data,
     return out;
 }
 
+static const char *md5_func(ap_expr_eval_ctx_t *ctx, const void *data,
+                               const char *arg)
+{
+       return ap_md5(ctx->p, (const unsigned char *)arg);
+}
+
+
 #define MAX_FILE_SIZE 10*1024*1024
 static const char *file_func(ap_expr_eval_ctx_t *ctx, const void *data,
                              char *arg)
@@ -1610,6 +1618,7 @@ static const struct expr_provider_single string_func_providers[] = {
     { base64_func,          "base64",         NULL, 0 },
     { unbase64_func,        "unbase64",       NULL, 0 },
     { sha1_func,            "sha1",           NULL, 0 },
+    { md5_func,             "md5",            NULL, 0 },
     { NULL, NULL, NULL}
 };