From bccad962ddef373ee6b51a5565b280a35c2657e4 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Mon, 15 Apr 2013 12:36:23 +0000 Subject: [PATCH] Merge r1457437, r1457520 from trunk: 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 | 7 ------- docs/manual/expr.xml | 5 +++++ server/util_expr_eval.c | 15 ++++++++++++++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/STATUS b/STATUS index 21c28219a1..11da99eb52 100644 --- 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 diff --git a/docs/manual/expr.xml b/docs/manual/expr.xml index c75c967ba1..13b5cee89a 100644 --- a/docs/manual/expr.xml +++ b/docs/manual/expr.xml @@ -459,6 +459,11 @@ listfunction ::= listfuncname "(" word ")" unescape Unescape %hex encoded string, leaving encoded slashes alone; return empty string if %00 is found + base64 + Encode the string using base64 encoding + unbase64 + Decode base64 encoded string, return truncated string if 0x00 is + found file Read contents from a fileyes filesize diff --git a/server/util_expr_eval.c b/server/util_expr_eval.c index b350cfc771..46bd4b6e85 100644 --- a/server/util_expr_eval.c +++ b/server/util_expr_eval.c @@ -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 }, -- 2.50.1