From 7053bedffefec30c8d1a70c12ed47dd0325ab8ca Mon Sep 17 00:00:00 2001 From: Herwin Weststrate Date: Thu, 14 Aug 2014 13:07:48 +0200 Subject: [PATCH] A number of fixes (mainly comments) of rlm_expr * Update the urlunquote example to make it copy-pastable by doubling the %. Add a comment why * Typo fix: s/wont'/won't/ * Removed UNUSED macro for *instance in (un)escape_xlat, it is being used here * Fix the unuescape example, the name here should be unescape, not escape * Added a ":" after "Example" in tolower. This makes it easier to find the examples in this file, since all other examples did this. --- src/modules/rlm_expr/rlm_expr.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/modules/rlm_expr/rlm_expr.c b/src/modules/rlm_expr/rlm_expr.c index 7b23befda8c0..28cad4a6e91b 100644 --- a/src/modules/rlm_expr/rlm_expr.c +++ b/src/modules/rlm_expr/rlm_expr.c @@ -486,7 +486,8 @@ static ssize_t urlquote_xlat(UNUSED void *instance, UNUSED REQUEST *request, /** URLdecode special characters * - * Example: "%{urlunquote:http%3A%47%47example.org%47}" == "http://example.org/" + * Example: "%{urlunquote:http%%3A%%47%%47example.org%%47}" == "http://example.org/" + * Mind the double % in the quoted string, otherwise unlang would start parsing it */ static ssize_t urlunquote_xlat(UNUSED void *instance, UNUSED REQUEST *request, char const *fmt, char *out, size_t outlen) @@ -505,7 +506,7 @@ static ssize_t urlunquote_xlat(UNUSED void *instance, UNUSED REQUEST *request, } /* Is a % char */ - /* Don't need \0 check, as it wont' be in the hextab */ + /* Don't need \0 check, as it won't be in the hextab */ if (!(c1 = memchr(hextab, tolower(*++p), 16)) || !(c2 = memchr(hextab, tolower(*++p), 16))) { REMARKER(fmt, p - fmt, "None hex char in % sequence"); @@ -524,7 +525,7 @@ static ssize_t urlunquote_xlat(UNUSED void *instance, UNUSED REQUEST *request, * * @verbatim Example: "%{escape:foo.jpg}" == "=60img=62foo.jpg=60/img=62" @endverbatim */ -static ssize_t escape_xlat(UNUSED void *instance, UNUSED REQUEST *request, +static ssize_t escape_xlat(void *instance, UNUSED REQUEST *request, char const *fmt, char *out, size_t outlen) { rlm_expr_t *inst = instance; @@ -561,9 +562,9 @@ static ssize_t escape_xlat(UNUSED void *instance, UNUSED REQUEST *request, /** Equivalent to the old safe_characters functionality in rlm_sql * - * @verbatim Example: "%{escape:=60img=62foo.jpg=60/img=62}" == "foo.jpg" @endverbatim + * @verbatim Example: "%{unescape:=60img=62foo.jpg=60/img=62}" == "foo.jpg" @endverbatim */ -static ssize_t unescape_xlat(UNUSED void *instance, UNUSED REQUEST *request, +static ssize_t unescape_xlat(void *instance, UNUSED REQUEST *request, char const *fmt, char *out, size_t outlen) { rlm_expr_t *inst = instance; @@ -605,7 +606,7 @@ static ssize_t unescape_xlat(UNUSED void *instance, UNUSED REQUEST *request, /** Convert a string to lowercase * - * Example "%{tolower:Bar}" == "bar" + * Example: "%{tolower:Bar}" == "bar" * * Probably only works for ASCII */