Skip to content

Commit

Permalink
A number of fixes (mainly comments) of rlm_expr
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
qnet-herwin authored and alandekok committed Aug 22, 2014
1 parent 600e331 commit 7053bed
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/modules/rlm_expr/rlm_expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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");
Expand All @@ -524,7 +525,7 @@ static ssize_t urlunquote_xlat(UNUSED void *instance, UNUSED REQUEST *request,
*
* @verbatim Example: "%{escape:<img>foo.jpg</img>}" == "=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;
Expand Down Expand Up @@ -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}" == "<img>foo.jpg</img>" @endverbatim
* @verbatim Example: "%{unescape:=60img=62foo.jpg=60/img=62}" == "<img>foo.jpg</img>" @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;
Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit 7053bed

Please sign in to comment.