From: Jim Jagielski Date: Mon, 22 Apr 2013 14:08:42 +0000 (+0000) Subject: Merge r1458004 from trunk: X-Git-Tag: 2.4.5~398 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=30e101aab32869ac02eae0ae52bd1d34314fa6f3;p=apache Merge r1458004 from trunk: 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 --- diff --git a/STATUS b/STATUS index 12bc2cb209..1e694815bf 100644 --- 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) diff --git a/docs/manual/expr.xml b/docs/manual/expr.xml index 12b8df1e4f..fead54319f 100644 --- a/docs/manual/expr.xml +++ b/docs/manual/expr.xml @@ -464,6 +464,9 @@ listfunction ::= listfuncname "(" word ")" unbase64 Decode base64 encoded string, return truncated string if 0x00 is found + md5 + Hash the string using MD5, then encode the hash with hexadecimal + encoding sha1 Hash the string using SHA1, then encode the hash with hexadecimal encoding diff --git a/server/util_expr_eval.c b/server/util_expr_eval.c index 92146a23c3..e3adf88ae1 100644 --- a/server/util_expr_eval.c +++ b/server/util_expr_eval.c @@ -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} };