]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
only mark strings for expansion when they contain '%'
authorAlan T. DeKok <aland@freeradius.org>
Sun, 23 Feb 2025 13:43:24 +0000 (08:43 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 23 Feb 2025 13:43:24 +0000 (08:43 -0500)
src/lib/pair.c

index c9f2f046819e4fe81b7ffca154f6132f3515e069..590c1e45ec3461ca8e6cdda1eaf23f146d7b5413 100644 (file)
@@ -1980,6 +1980,8 @@ FR_TOKEN fr_pair_list_afrom_str(TALLOC_CTX *ctx, char const *buffer, VALUE_PAIR
 
        p = buffer;
        do {
+               char const *q;
+
                raw.l_opand[0] = '\0';
                raw.r_opand[0] = '\0';
 
@@ -1995,7 +1997,16 @@ FR_TOKEN fr_pair_list_afrom_str(TALLOC_CTX *ctx, char const *buffer, VALUE_PAIR
                }
                if (last_token == T_INVALID) break;
 
-               if (raw.quote == T_DOUBLE_QUOTED_STRING) {
+               /*
+                *      Mark double-quoted strings as being expanded,
+                *      but only if they contain a '%' character.
+                *
+                *      Note that this check is a bit too narrow, but
+                *      most of the time it avoids marking the string
+                *      for expansion.
+                */
+               if ((raw.quote == T_DOUBLE_QUOTED_STRING) &&
+                   (((q = strchr(raw.r_opand, '%')) != NULL) || !q[1])) {
                        vp = fr_pair_make(ctx, NULL, raw.l_opand, NULL, raw.op);
                        if (!vp) {
                                last_token = T_INVALID;