Skip to content

Commit 9771a82

Browse files
committed
Add the escapehtml function to the expression API
Add the escapehtml function to the expression API, allowing to escape HTML strings to guard against HTML injections. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1926342 13f79535-47bb-0310-9956-ffa450edef68
1 parent af61c91 commit 9771a82

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

changes-entries/escapehtml.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*) Add the escapehtml function to the expression API, allowing to escape HTML
2+
strings to guard against HTML injections. [Ruediger Pluem]

docs/manual/expr.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,8 @@ DIGIT ::= <any US-ASCII digit "0".."9">
605605
<td>replace(string, "from", "to") replaces all occurrences of "from"
606606
in the string with "to". The first parameter must not be a literal string.
607607
</td><td></td></tr>
608+
<tr><td><code>escapehtml</code></td>
609+
<td>Escape a HTML string</td><td></td></tr>
608610

609611
</table>
610612

server/util_expr_eval.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,12 @@ static const char *ldap_func(ap_expr_eval_ctx_t *ctx, const void *data,
14221422
}
14231423
#endif
14241424

1425+
static const char *escapehtml_func(ap_expr_eval_ctx_t *ctx, const void *data,
1426+
const char *arg)
1427+
{
1428+
return ap_escape_html(ctx->p, arg);
1429+
}
1430+
14251431
static int replace_func_parse_arg(ap_expr_lookup_parms *parms)
14261432
{
14271433
const char *original = parms->arg;
@@ -2092,6 +2098,7 @@ static const struct expr_provider_single string_func_providers[] = {
20922098
{ ldap_func, "ldap", NULL, 0 },
20932099
#endif
20942100
{ replace_func, "replace", replace_func_parse_arg, 0 },
2101+
{ escapehtml_func, "escapehtml", NULL, 0 },
20952102
{ NULL, NULL, NULL}
20962103
};
20972104

0 commit comments

Comments
 (0)