You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2013/04/15 14:41:23 UTC
svn commit: r1467979 - in /httpd/httpd/branches/2.4.x: ./ STATUS
docs/manual/ docs/manual/expr.xml server/util_expr_eval.c
Author: jim
Date: Mon Apr 15 12:41:23 2013
New Revision: 1467979
URL: http://svn.apache.org/r1467979
Log:
Merge r1457450, r1457610, r1457995, r1458003 from trunk:
Expression parser: Add the ability to apply a SHA1 hash to strings within
the parser.
Expression parser: use hex encoding for the sha1 hash.
sha1 now does hex encoding
simplify code by using ap_bin2hex()
Submitted by: minfrin, sf, sf
Reviewed/backported by: jim
Modified:
httpd/httpd/branches/2.4.x/ (props changed)
httpd/httpd/branches/2.4.x/STATUS
httpd/httpd/branches/2.4.x/docs/manual/ (props changed)
httpd/httpd/branches/2.4.x/docs/manual/expr.xml
httpd/httpd/branches/2.4.x/server/util_expr_eval.c
Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
Merged /httpd/httpd/trunk:r1457450,1457610,1457995,1458003
Modified: httpd/httpd/branches/2.4.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/STATUS?rev=1467979&r1=1467978&r2=1467979&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/STATUS (original)
+++ httpd/httpd/branches/2.4.x/STATUS Mon Apr 15 12:41:23 2013
@@ -90,15 +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 SHA1 hash to
- strings within the parser.
- trunk patch: http://svn.apache.org/r1457450
- http://svn.apache.org/r1457610
- http://svn.apache.org/r1457995
- http://svn.apache.org/r1458003
- 2.4.x patch: trunk patch applies.
- +1: minfrin, rjung, jim
-
* remove useless tests ==> (*x && apr_isspace(*x))
trunk patch: http://svn.apache.org/viewvc?view=revision&revision=1452128
2.4.x patch: trunk patch works (with some offset)
Propchange: httpd/httpd/branches/2.4.x/docs/manual/
------------------------------------------------------------------------------
Merged /httpd/httpd/trunk/docs/manual:r1457450,1457995
Modified: httpd/httpd/branches/2.4.x/docs/manual/expr.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/docs/manual/expr.xml?rev=1467979&r1=1467978&r2=1467979&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/docs/manual/expr.xml (original)
+++ httpd/httpd/branches/2.4.x/docs/manual/expr.xml Mon Apr 15 12:41:23 2013
@@ -464,6 +464,9 @@ listfunction ::= listfuncname "<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>sha1</code></td>
+ <td>Hash the string using SHA1, then encode the hash with hexadecimal
+ encoding</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>
Modified: httpd/httpd/branches/2.4.x/server/util_expr_eval.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/server/util_expr_eval.c?rev=1467979&r1=1467978&r2=1467979&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/server/util_expr_eval.c (original)
+++ httpd/httpd/branches/2.4.x/server/util_expr_eval.c Mon Apr 15 12:41:23 2013
@@ -28,6 +28,8 @@
#include "apr_lib.h"
#include "apr_fnmatch.h"
+#include "apr_base64.h"
+#include "apr_sha1.h"
#include <limits.h> /* for INT_MAX */
@@ -1031,6 +1033,24 @@ static const char *unbase64_func(ap_expr
return ap_pbase64decode(ctx->p, arg);
}
+static const char *sha1_func(ap_expr_eval_ctx_t *ctx, const void *data,
+ const char *arg)
+{
+ apr_sha1_ctx_t context;
+ apr_byte_t sha1[APR_SHA1_DIGESTSIZE];
+ char *out;
+
+ out = apr_palloc(ctx->p, APR_SHA1_DIGESTSIZE*2+1);
+
+ apr_sha1_init(&context);
+ apr_sha1_update(&context, arg, strlen(arg));
+ apr_sha1_final(sha1, &context);
+
+ ap_bin2hex(sha1, APR_SHA1_DIGESTSIZE, out);
+
+ return out;
+}
+
#define MAX_FILE_SIZE 10*1024*1024
static const char *file_func(ap_expr_eval_ctx_t *ctx, const void *data,
char *arg)
@@ -1589,6 +1609,7 @@ static const struct expr_provider_single
{ filesize_func, "filesize", NULL, 1 },
{ base64_func, "base64", NULL, 0 },
{ unbase64_func, "unbase64", NULL, 0 },
+ { sha1_func, "sha1", NULL, 0 },
{ NULL, NULL, NULL}
};