]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
remove fr_pair_mark_xlat(), as nothing uses it
authorAlan T. DeKok <aland@freeradius.org>
Fri, 10 Dec 2021 21:35:06 +0000 (16:35 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 10 Dec 2021 21:37:00 +0000 (16:37 -0500)
src/lib/util/pair_legacy.c
src/lib/util/pair_legacy.h
src/lib/util/pair_legacy_tests.c

index 846994fd634deb3825b8e6e9486742b0d83e6c54..2aa6b428541974b58e868c0ea0e0b44560ecff40 100644 (file)
@@ -55,41 +55,6 @@ static fr_sbuff_term_t const         bareword_terminals =
                                        L("||"),                /* Logical operator */
                                );
 
-/** Mark a valuepair for xlat expansion
- *
- * Copies xlat source (unprocessed) string to valuepair value, and sets value type.
- *
- * @param vp to mark for expansion.
- * @param value to expand.
- * @return
- *     - 0 if marking succeeded.
- *     - -1 if #fr_pair_t already had a value, or OOM.
- */
-int fr_pair_mark_xlat(fr_pair_t *vp, char const *value)
-{
-       char *raw;
-
-       /*
-        *      valuepair should not already have a value.
-        */
-       if (vp->type != VT_NONE) {
-               fr_strerror_const("Pair already has a value");
-               return -1;
-       }
-
-       raw = talloc_typed_strdup(vp, value);
-       if (!raw) {
-               fr_strerror_const("Out of memory");
-               return -1;
-       }
-
-       vp->type = VT_XLAT;
-       vp->xlat = raw;
-       vp->vp_length = 0;
-
-       return 0;
-}
-
 /** Create a valuepair from an ASCII attribute and value
  *
  * Where the attribute name is in the form:
@@ -222,7 +187,7 @@ static ssize_t fr_pair_list_afrom_substr(TALLOC_CTX *ctx, fr_dict_attr_t const *
        fr_pair_list_t          tmp_list;
        fr_pair_t               *vp = NULL;
        fr_pair_t               *my_relative_vp;
-       char const              *p, *q, *next;
+       char const              *p, *next;
        fr_token_t              quote, last_token = T_INVALID;
        fr_pair_t_RAW           raw;
        fr_dict_attr_t const    *internal = NULL;
@@ -401,22 +366,7 @@ static ssize_t fr_pair_list_afrom_substr(TALLOC_CTX *ctx, fr_dict_attr_t const *
                        }
 
                        switch (quote) {
-                               /*
-                                *      Perhaps do xlat's
-                                */
                        case T_DOUBLE_QUOTED_STRING:
-                               /*
-                                *      Only report as double quoted if it contained valid
-                                *      a valid xlat expansion.
-                                */
-                               q = strchr(raw.r_opand, '%');
-                               if (q && (q[1] == '{')) {
-                                       raw.quote = quote;
-                               } else {
-                                       raw.quote = T_SINGLE_QUOTED_STRING;
-                               }
-                               break;
-
                        case T_SINGLE_QUOTED_STRING:
                        case T_BACK_QUOTED_STRING:
                        case T_BARE_WORD:
@@ -449,18 +399,10 @@ static ssize_t fr_pair_list_afrom_substr(TALLOC_CTX *ctx, fr_dict_attr_t const *
                                 *      ignore it.
                                 */
                                break;
+                       }
 
-                               /*
-                                *      fr_pair_raw_from_str() only returns this when
-                                *      the input looks like it needs to be xlat'd.
-                                */
-                       } if (raw.quote == T_DOUBLE_QUOTED_STRING) {
-                               if (fr_pair_mark_xlat(vp, raw.r_opand) < 0) {
-                                       talloc_free(vp);
-                                       goto error;
-                               }
-                       } else if (fr_pair_value_from_str(vp, raw.r_opand, strlen(raw.r_opand),
-                                                         fr_value_unescape_by_quote[quote], false) < 0) {
+                       if (fr_pair_value_from_str(vp, raw.r_opand, strlen(raw.r_opand),
+                                                  fr_value_unescape_by_quote[quote], false) < 0) {
                                talloc_free(vp);
                                goto error;
                        }
index 0afb5bcda95173ce895d1f17439e7035a05f9fd5..9568adac34d6c63c5525ac2e1d5c738ad0d55e42 100644 (file)
@@ -37,8 +37,6 @@ extern "C" {
 fr_pair_t      *fr_pair_make(TALLOC_CTX *ctx, fr_dict_t const *dict,
                              fr_pair_list_t *vps, char const *attribute, char const *value);
 
-int            fr_pair_mark_xlat(fr_pair_t *vp, char const *value);
-
 fr_token_t     fr_pair_list_afrom_str(TALLOC_CTX *ctx, fr_dict_t const *dict,
                                       char const *buffer, size_t len, fr_pair_list_t *head);
 int            fr_pair_list_afrom_file(TALLOC_CTX *ctx, fr_dict_t const *dict,
index 1b75e641a3017c27ce3e21ff0229c8db1d58e8d7..e9f4bef8c93e70138ca2a341fe0db9e6758c893a 100644 (file)
@@ -103,29 +103,6 @@ static void test_fr_pair_make(void)
        fr_pair_list_free(&list);
 }
 
-static void test_fr_pair_mark_xlat(void)
-{
-       fr_pair_t  *vp;
-
-       TEST_CASE("Find 'Test-String-0'");
-       TEST_CHECK((vp = fr_pair_find_by_da_idx(&test_pairs, fr_dict_attr_test_string, 0)) != NULL);
-
-       TEST_CASE("Validating PAIR_VERIFY()");
-       PAIR_VERIFY(vp);
-
-       TEST_CASE("Marking 'vp' using fr_pair_mark_xlat()");
-       TEST_CHECK(fr_pair_mark_xlat(vp, "Hello %{Test-Uint32-0}") == 0);
-
-       TEST_CASE("Validating PAIR_VERIFY()");
-       PAIR_VERIFY(vp);
-
-       TEST_CASE("Check (vp->xlat == 'Hello %{Test-Uint32-0}')");
-       TEST_CHECK(vp && strcmp(vp->xlat, "Hello %{Test-Uint32-0}") == 0);
-       TEST_CHECK(vp && vp->type == VT_XLAT);
-
-       talloc_free(vp);
-}
-
 static void test_fr_pair_list_afrom_str(void)
 {
        fr_pair_t      *vp;
@@ -260,7 +237,6 @@ TEST_LIST = {
         *      Legacy calls
         */
        { "fr_pair_make",            test_fr_pair_make },
-       { "fr_pair_mark_xlat",       test_fr_pair_mark_xlat },
        { "fr_pair_list_afrom_str",  test_fr_pair_list_afrom_str },
        { "fr_pair_list_afrom_file", test_fr_pair_list_afrom_file },
        { "fr_pair_list_move_op",       test_fr_pair_list_move_op },