]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
quote strings are strings
authorAlan T. DeKok <aland@freeradius.org>
Thu, 8 May 2025 01:40:06 +0000 (21:40 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 8 May 2025 01:40:06 +0000 (21:40 -0400)
src/lib/server/tmpl_eval.c
src/lib/unlang/xlat_tokenize.c
src/tests/keywords/switch-string [new file with mode: 0644]

index e0acc1530e5b7e156472359de2c63d14be22f72f..d19ff0f96bae0834a160725bcc94906abd9ec367 100644 (file)
@@ -1336,6 +1336,8 @@ fr_type_t tmpl_data_type(tmpl_t const *vpt)
 {
        if (tmpl_rules_cast(vpt) != FR_TYPE_NULL) return tmpl_rules_cast(vpt);
 
+       if (vpt->quote != T_BARE_WORD) return FR_TYPE_STRING;
+
        if (tmpl_is_data(vpt)) return tmpl_value_type(vpt);
 
        if (tmpl_is_attr(vpt)) return tmpl_attr_tail_da(vpt)->type;
index 2699e0106b9345dfdbfda0faa146ddc89f92e873..d6c6f6b525f724a06de3bf8316a4f323f0d63fd9 100644 (file)
@@ -2069,6 +2069,8 @@ fr_type_t xlat_data_type(xlat_exp_head_t const *head)
 
        if (xlat_exp_next(head, node)) return FR_TYPE_NULL;
 
+       if (node->quote != T_BARE_WORD) return FR_TYPE_STRING;
+
        if (node->type == XLAT_FUNC) {
                return node->call.func->return_type;
        }
diff --git a/src/tests/keywords/switch-string b/src/tests/keywords/switch-string
new file mode 100644 (file)
index 0000000..2b23aa0
--- /dev/null
@@ -0,0 +1,19 @@
+#
+# PRE: switch
+#
+
+switch "%str.substr(%{User-Name}, 0, 3)" {
+       case 'bob' {
+               success
+       }
+
+       case 'doug' {
+               Filter-Id := "doug"
+               test_fail
+       }
+
+       default {
+               Filter-Id := "default"
+               test_fail
+       }
+}