A number of fixes (mainly comments) of rlm_expr release_3_0_4_rc2
authorHerwin Weststrate <herwin@quarantainenet.nl>
Thu, 14 Aug 2014 11:07:48 +0000 (13:07 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 22 Aug 2014 11:20:11 +0000 (07:20 -0400)
* 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

index 7b23bef..28cad4a 100644 (file)
@@ -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:<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;
@@ -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;
@@ -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
  */