]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
fix nested %{...}
authorAlan T. DeKok <aland@freeradius.org>
Tue, 10 Sep 2019 14:45:54 +0000 (10:45 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 10 Sep 2019 14:45:54 +0000 (10:45 -0400)
src/lib/server/tmpl.c
src/tests/unit/condition.txt

index 27b80946a1b929a58c88a3a0c317c7668184ab18..ac323149938332ddbc0963d902b6903180669177 100644 (file)
@@ -3056,7 +3056,7 @@ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *start,
                 *      / lists on their own.
                 */
                *type = T_DOUBLE_QUOTED_STRING;
-               depth = 1;
+               depth = 0;
 
                /*
                 *      Xlat's are quoted by %{...} nesting, not by
@@ -3090,7 +3090,7 @@ ssize_t tmpl_preparse(char const **out, size_t *outlen, char const *start,
                                continue;
                        }
 
-                       if ((*p == '%') && (*p == '{')) {
+                       if ((p[0] == '%') && (p[1] == '{')) {
                                if (!p[2]) {
                                        return_P("End of string after expansion");
                                }
index faa9c61774e7629cccf12e3e2e6062139aaaf0c2..975608b233d67137313e482e18357a65bc3b9216 100644 (file)
@@ -242,6 +242,9 @@ data <ipaddr>127.0.0.1 == "%{sql: 127.0.0.1}"
 condition <ipaddr>127.0.0.1 == %{sql:127.0.0.1}
 data <ipaddr>127.0.0.1 == "%{sql:127.0.0.1}"
 
+condition <ipaddr>127.0.0.1 == %{sql: SELECT user FROM table WHERE user='%{User-Name}'}
+data <ipaddr>127.0.0.1 == "%{sql: SELECT user FROM table WHERE user='%{User-Name}'}"
+
 condition <ether> 00:11:22:33:44:55 == "00:11:22:33:44:55"
 data true