]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
replace %{1} with %regex.match(1)
authorAlan T. DeKok <aland@freeradius.org>
Tue, 29 Apr 2025 14:46:24 +0000 (10:46 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 29 Apr 2025 18:01:47 +0000 (14:01 -0400)
like some other languages.

The unfortunate outcome is that this makes a lot of things much
more complex visually.  But it's a bit more consistent with the
rest of the xlat functions.  And, for the v4 way of "less magic
and fewer special cases".

For now, %{1} etc. is still functional

and enable %regex.match() in non-PCRE builds

23 files changed:
doc/antora/modules/howto/pages/protocols/dhcp/policy_device_options.adoc
doc/antora/modules/reference/pages/raddb/sites-available/coa-relay.adoc
doc/antora/modules/reference/pages/raddb/sites-available/vmps.adoc
doc/antora/modules/reference/pages/unlang/condition/regex.adoc
doc/antora/modules/reference/pages/xlat/builtin.adoc
src/lib/unlang/xlat_builtin.c
src/tests/digest/config/digest.conf
src/tests/keywords/foreach-break-2
src/tests/keywords/foreach-regex
src/tests/keywords/foreach-varied-depth
src/tests/keywords/if-regex-empty
src/tests/keywords/if-regex-match
src/tests/keywords/if-regex-match-comp
src/tests/keywords/if-regex-match-named
src/tests/keywords/if-regex-multivalue
src/tests/keywords/truncation
src/tests/keywords/xlat-inline
src/tests/ldap_sync/active_directory/config/radiusd.conf
src/tests/modules/eap_sim/sim_xlat_id_aka.unlang
src/tests/modules/eap_sim/sim_xlat_id_aka_decrypt_no_tag.unlang
src/tests/modules/sqlcounter/test.unlang
src/tests/unit/xlat/expr.txt
src/tests/unit/xlat/purify.txt

index 17bcf220331224cc8db7ba4e1b52283e8785fbd2..b2e0c1d0d110b575afe3ff27bc4556d4437a604a 100644 (file)
@@ -99,7 +99,7 @@ provided that it matches the given format:
 if (DHCP-Client-Identifier && \
         "%{string:DHCP-Client-Identifier}" =~ /^RAS([0-9])-site([A-Z])$/) {
     update reply {
-        DHCP-Boot-Filename := "rasboot-%{1}-%{2}.kpxe"
+        DHCP-Boot-Filename := "rasboot-%regex.match(1)-%regex.match(2).kpxe"
     }
 }
 ----
index c35d6766f4f5077b344e07b79011eed34d49d4ef..9d3f6c21988abe7b9c77c080bb5229921ed18458 100644 (file)
@@ -175,12 +175,12 @@ Send an update for each session we find.
 ```
 NAS-IP-Address
 ```
-                                       control.NAS-IP-Address := "%{1}"
+                                       control.NAS-IP-Address := "%regex.match(1)"
 
 ```
 Acct-Session-Id
 ```
-                                       control.Acct-Session-Id := "%{2}"
+                                       control.Acct-Session-Id := "%regex.match(2)"
 
                                        subrequest CoA-Request {
 ```
index 2aa454f3d8158a5e26695a2d9c78edfd6c6a680e..193e04a449940a72c4b7b3302b8038b07739ebe5 100644 (file)
@@ -86,7 +86,7 @@ create one using other attributes.
 ```
                if (!MAC-Address) {
                        if (Ethernet-Frame =~ /0x.{12}(..)(..)(..)(..)(..)(..).*/) {
-                               request.MAC-Address = "%{1}:%{2}:%{3}:%{4}:%{5}:%{6}"
+                               request.MAC-Address = "%regex.match(1):%regex.match(2):%regex.match(3):%regex.match(4):%regex.match(5):%regex.match(6)"
                        }
                        else {
                                request.MAC-Address = Cookie
index 848370c97f44edb57c4015adbdc35e066deaf454..db9596bdee0e0420e0b7bfd5f1ede375b84ec666 100644 (file)
@@ -113,9 +113,9 @@ library the server was built with.  Multiple flags may be specified per
 When the `=~` or `!~` operators are used, then parentheses in the regular
 expression will sub capture groups, which contain part of the subject string.
 
-The special expansion `%{0}` expands to the portion of the subject that
+The special expansion `%regex.match(0)` expands to the portion of the subject that
 matched. The expansions +
-`%{1}`..`%{32}` expand to the contents of any subcapture groups.
+`%regex.match(1)`..`%regex.match(32)` expand to the contents of any subcapture groups.
 
 When using libpcre[2], named capture groups may also be accessed using the
 built-in expansion +
@@ -130,7 +130,7 @@ more information on regular expression matching.
 ----
 if (User-Name =~ /^(.*)@example\.com$/) {
     reply += {
-        Reply-Message = "Hello %{1}"
+        Reply-Message = "Hello %regex.match(1)"
     }
 }
 ----
index 80a205624a00935c21cfc203df707f9d5c5fab57..5d0558606f2ea5530e124f8f8a0968693793f210 100644 (file)
@@ -83,10 +83,10 @@ Module rlm_exec.shell_escape = yes
 
 == Miscellaneous Expansions
 
-=== %{0}+..+%{32}
+=== %regex.match(0)+..+%regex.match(32)
 
-`%{0}` expands to the portion of the subject that matched the last regular
-expression evaluated. `%{1}`..`%{32}` expand to the contents of any capture
+`%regex.match(0)` expands to the portion of the subject that matched the last regular
+expression evaluated. `%regex.match(1)`..`%regex.match(32)` expand to the contents of any capture
 groups in the pattern.
 
 Every time a regular expression is evaluated, whether it matches or not,
index 00a85488d9f2b98247f55b16da866946d48ff18f..5a4b5ab70fe9bb501ee02a69e1c1c51741157106 100644 (file)
@@ -2778,7 +2778,6 @@ static int CC_HINT(nonnull(2,3)) regex_xlat_escape(UNUSED request_t *request, fr
        return 0;
 }
 
-#if defined(HAVE_REGEX_PCRE) || defined(HAVE_REGEX_PCRE2)
 static xlat_arg_parser_t const xlat_func_regex_args[] = {
        { .variadic = XLAT_ARG_VARIADIC_EMPTY_KEEP, .type = FR_TYPE_VOID },
        XLAT_ARG_PARSER_TERMINATOR
@@ -2858,6 +2857,7 @@ static xlat_action_t xlat_func_regex(TALLOC_CTX *ctx, fr_dcursor_t *out,
        }
 
        default:
+#if defined(HAVE_REGEX_PCRE) || defined(HAVE_REGEX_PCRE2)
        {
                fr_value_box_t  *vb;
 
@@ -2882,9 +2882,12 @@ static xlat_action_t xlat_func_regex(TALLOC_CTX *ctx, fr_dcursor_t *out,
 
                return XLAT_ACTION_DONE;
        }
+#else
+       RDEBUG("Named regex captures are not supported (they require libpcre2)");
+       return XLAT_ACTION_FAIL;
+#endif
        }
 }
-#endif
 
 static xlat_arg_parser_t const xlat_func_sha_arg[] = {
        { .concat = true, .type = FR_TYPE_OCTETS },
@@ -4332,7 +4335,6 @@ do { \
        XLAT_REGISTER_PURE("md5", xlat_func_md5, FR_TYPE_OCTETS, xlat_func_md5_arg);
        XLAT_NEW("hash.md4");
 
-#if defined(HAVE_REGEX_PCRE) || defined(HAVE_REGEX_PCRE2)
        if (unlikely((xlat = xlat_func_register(xlat_ctx, "regex.match", xlat_func_regex, FR_TYPE_STRING)) == NULL)) return -1;
        xlat_func_args_set(xlat, xlat_func_regex_args);
        xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_INTERNAL);
@@ -4340,7 +4342,6 @@ do { \
        xlat_func_args_set(xlat, xlat_func_regex_args);
        xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_INTERNAL);
        XLAT_NEW("regex.match");
-#endif
 
        {
                static xlat_arg_parser_t const xlat_regex_safe_args[] = {
index b082434ec040913273c7bf924ee98781f616e2f7..da59254e9e9f18c112fa49b20ac09d64eae157d8 100644 (file)
@@ -125,7 +125,7 @@ recv Access-Request {
        }
 
        if (User-Name =~ /^(.*)@test\.example\.com$/) {
-               Stripped-User-Name := "%{1}"
+               Stripped-User-Name := "%regex.match(1)"
                control.Password.Cleartext := "bob"
        }
 
index 51cfcab77e256e15966d844f3f9b3a454ab80c50..269ec5817482b96b87e6795f995738d4f6117d9f 100644 (file)
@@ -12,7 +12,7 @@ control.User-Name := { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b
 
 foreach thing (control.User-Name) {
        if (test_string =~ /([A-Z0-9\-]*)_%{thing}/) {
-               test_string := %{1}
+               test_string := %regex.match(1)
                success
                break
        }
index e0e35c08e5db56276b7f2068310c03b8b3f59d98..adfcef62224cedefdd9af27401af979738f2dc7b 100644 (file)
@@ -9,7 +9,7 @@ cisco_prefix := "cisco"
 foreach value (Vendor-Specific.Cisco.AVPair) {
        if (value  =~ /^%{cisco_prefix}=(.*)$/i) {
                reply += {
-                       Called-Station-Id = %{1}
+                       Called-Station-Id = %regex.match(1)
                }
        }
 }
@@ -18,7 +18,7 @@ foreach value (Vendor-Specific.Cisco.AVPair) {
 foreach value (Vendor-Specific.Cisco.AVPair) {
        if (value  =~ /^stupid=(.*)$/i) {
                reply += {
-                       Called-Station-Id = %{1}
+                       Called-Station-Id = %regex.match(1)
                }
        }
 }
index a32ae52470ff02e771752f69d9ecc9227e2727bd..03b5db0734ab1286100e27c3c8e3b465f1969e15 100644 (file)
@@ -8,9 +8,7 @@ control += {
 
 if (User-Name) {
        foreach thing (control.Filter-Id[*]) {
-               if (thing =~ /(.*)/) {
-                       control.Calling-Station-Id := %{1}
-               }
+               control.Calling-Station-Id := thing
        }
 }
 
@@ -21,9 +19,7 @@ if (!(control.Calling-Station-Id == 'ssid=GHIJKL')) {
 control -= Calling-Station-Id[*]
 
 foreach thing (control.Filter-Id) {
-       if (thing =~ /(.*)/) {
-               control.Calling-Station-Id := %{1}
-       }
+       control.Calling-Station-Id := thing
 }
 
 if (!(control.Calling-Station-Id == 'ssid=GHIJKL')) {
index d3df1d733f63e17c1862e4ce6b94d17bec783c26..21e6e970de732e6bb69f23e0a684c31a107fd84c 100644 (file)
@@ -9,16 +9,16 @@ if !(control.Password.Cleartext =~ /hell(o)(.*)/) {
 #
 #  Verify non-empty capture groups evaluate to true
 #
-#  Note that "%{1}" evaluates to an empty string!
+#  Note that "%regex.match(1)" evaluates to an empty string!
 #
-if !%{1} {
+if !%regex.match(1) {
        test_fail
 }
 
 #
 #  Verify empty capture groups evaluate to false
 #
-if %{2} {
+if %regex.match(2) {
        test_fail
 }
 
@@ -29,7 +29,7 @@ if !(control.Password.Cleartext =~ /hello(.*)/) {
 #
 #  Check for stale capture group values
 #
-if %{1} {
+if %regex.match(1) {
        test_fail
 }
 
@@ -37,7 +37,7 @@ if %{1} {
 #  Check assignment of regex null-match
 #
 if (control.Password.Cleartext =~ /hell(o)(.*)/) {
-       control.Filter-Id := "%{2}"
+       control.Filter-Id := "%regex.match(2)"
 }
 
 if (!control.Filter-Id) {
index a1f21a3db43f1b17930f15399d99e6032d04597c..7d40d7ea31502163d5e2b82f65dc7cf84c85cfc5 100644 (file)
@@ -19,7 +19,7 @@ if !("%{User-Name}" =~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])%{
 # Matching on attribute ref with capture groups
 if (User-Name =~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])%{test_string}/) {
        # Test all the capture groups
-       reply.User-Name := "%{7}_%{6}_%{5}_%{4}_%{3}_%{2}_%{1}_%{0}"
+       reply.User-Name := "%regex.match(7)_%regex.match(6)_%regex.match(5)_%regex.match(4)_%regex.match(3)_%regex.match(2)_%regex.match(1)_%regex.match(0)"
 }
 else {
        test_fail
@@ -27,7 +27,7 @@ else {
 
 # Checking capture groups are cleared out correctly
 if (User-Name =~ /^([0-9])_%{test_string}/) {
-       if (!("%{0}%{1}%{2}%{3}%{4}%{5}%{6}%{7}" == '1_1')) {
+       if (!("%regex.match(0)%regex.match(1)%regex.match(2)%regex.match(3)%regex.match(4)%regex.match(5)%regex.match(6)%regex.match(7)" == '1_1')) {
                test_fail
        }
 }
@@ -37,7 +37,7 @@ else {
 
 # Checking capture groups are cleared out correctly when there are no matches
 if (User-Name =~ /^.%{test_string}/) {
-       if (!("%{0}%{1}%{2}%{3}%{4}%{5}%{6}%{7}" == '1')) {
+       if (!("%regex.match(0)%regex.match(1)%regex.match(2)%regex.match(3)%regex.match(4)%regex.match(5)%regex.match(6)%regex.match(7)" == '1')) {
                test_fail
        }
 }
@@ -47,7 +47,7 @@ else {
 
 # Checking full capture group range
 if ('a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z_A_B_C_D_E_F' =~ /^(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)$/) {
-       if (!("%{0}%{1}%{2}%{3}%{4}%{5}%{6}%{7}%{8}%{9}%{10}%{11}%{12}%{13}%{14}%{15}%{16}%{17}%{18}%{19}%{20}%{21}%{22}%{23}%{24}%{25}%{26}%{27}%{28}%{29}%{30}%{31}%{32}" == 'a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z_A_B_C_D_E_FabcdefghijklmnopqrstuvwxyzABCDEF')) {
+       if (!("%regex.match(0)%regex.match(1)%regex.match(2)%regex.match(3)%regex.match(4)%regex.match(5)%regex.match(6)%regex.match(7)%regex.match(8)%regex.match(9)%regex.match(10)%regex.match(11)%regex.match(12)%regex.match(13)%regex.match(14)%regex.match(15)%regex.match(16)%regex.match(17)%regex.match(18)%regex.match(19)%regex.match(20)%regex.match(21)%regex.match(22)%regex.match(23)%regex.match(24)%regex.match(25)%regex.match(26)%regex.match(27)%regex.match(28)%regex.match(29)%regex.match(30)%regex.match(31)%regex.match(32)" == 'a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z_A_B_C_D_E_FabcdefghijklmnopqrstuvwxyzABCDEF')) {
                test_fail
        }
 }
@@ -57,7 +57,7 @@ else {
 
 # Checking full capture group overrun
 if ('a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z_A_B_C_D_E_F_G' =~ /^(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)_(.)$/) {
-       if (!("%{0}%{1}%{2}%{3}%{4}%{5}%{6}%{7}%{8}%{9}%{10}%{11}%{12}%{13}%{14}%{15}%{16}%{17}%{18}%{19}%{20}%{21}%{22}%{23}%{24}%{25}%{26}%{27}%{28}%{29}%{30}%{31}%{32}" == 'a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z_A_B_C_D_E_F_GabcdefghijklmnopqrstuvwxyzABCDEF')) {
+       if (!("%regex.match(0)%regex.match(1)%regex.match(2)%regex.match(3)%regex.match(4)%regex.match(5)%regex.match(6)%regex.match(7)%regex.match(8)%regex.match(9)%regex.match(10)%regex.match(11)%regex.match(12)%regex.match(13)%regex.match(14)%regex.match(15)%regex.match(16)%regex.match(17)%regex.match(18)%regex.match(19)%regex.match(20)%regex.match(21)%regex.match(22)%regex.match(23)%regex.match(24)%regex.match(25)%regex.match(26)%regex.match(27)%regex.match(28)%regex.match(29)%regex.match(30)%regex.match(31)%regex.match(32)" == 'a_b_c_d_e_f_g_h_i_j_k_l_m_n_o_p_q_r_s_t_u_v_w_x_y_z_A_B_C_D_E_F_GabcdefghijklmnopqrstuvwxyzABCDEF')) {
                test_fail
        }
 }
index 498a514646b713d4dec0913fc2fa07f2bf4916a4..80e90fabedbdd612a88bce40e192ecf87e7d9424 100644 (file)
@@ -15,7 +15,7 @@ if !("%{User-Name}" =~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])/)
 # Matching on attribute ref with capture groups
 if (User-Name =~ /^([0-9])_([0-9])?_([0-9]*)_([0-9]+)_([^_])_(6)_([7-8])/) {
        # Test all the capture groups
-       reply.User-Name := "%{7}_%{6}_%{5}_%{4}_%{3}_%{2}_%{1}_%{0}"
+       reply.User-Name := "%regex.match(7)_%regex.match(6)_%regex.match(5)_%regex.match(4)_%regex.match(3)_%regex.match(2)_%regex.match(1)_%regex.match(0)"
 }
 else {
        test_fail
@@ -23,7 +23,7 @@ else {
 
 # Checking capture groups are cleared out correctly
 if (User-Name =~ /^([0-9])_/) {
-       if (!("%{0}%{1}%{2}%{3}%{4}%{5}%{6}%{7}" == '1_1')) {
+       if (!("%regex.match(0)%regex.match(1)%regex.match(2)%regex.match(3)%regex.match(4)%regex.match(5)%regex.match(6)%regex.match(7)" == '1_1')) {
                test_fail
        }
 }
@@ -33,7 +33,7 @@ else {
 
 # Checking capture groups are cleared out correctly when there are no matches
 if (User-Name =~ /^./) {
-       if (!("%{0}%{1}%{2}%{3}%{4}%{5}%{6}%{7}" == '1')) {
+       if (!("%regex.match(0)%regex.match(1)%regex.match(2)%regex.match(3)%regex.match(4)%regex.match(5)%regex.match(6)%regex.match(7)" == '1')) {
                test_fail
        }
 }
index e86a52a0366ba316429ce308975905b36e15cc9f..be8a8da1d6b852fc64290de24b6cc725dcaddb3d 100644 (file)
@@ -44,7 +44,7 @@ request -= Module-Failure-Message[*]
 
 # uncompiled - ref - named capture groups
 if (User-Name =~ /^(?<one>[0-9])_(?<two>[0-9])?_(?<three>[0-9]*)_(?<four>[0-9]+)_(?<five>[^_])_(?<six>6)_(?<seven>[7-8])%{dummy_string}/) {
-       result_string := "%regex.match('seven')_%regex.match('six')_%regex.match('five')_%regex.match('four')_%regex.match('three')_%regex.match('two')_%regex.match('one')_%{0}"
+       result_string := "%regex.match('seven')_%regex.match('six')_%regex.match('five')_%regex.match('four')_%regex.match('three')_%regex.match('two')_%regex.match('one')_%regex.match(0)"
        if (!(result_string == '7_6_5_4_3_2_1_1_2_3_4_5_6_7')) {
                test_fail
        }
@@ -55,7 +55,7 @@ else {
 
 # Checking capture groups are cleared out correctly
 if (User-Name =~ /^(?<one>[0-9])_%{dummy_string}/) {
-       result_string := "%{0}%regex.match('one')%regex.match('two')%regex.match('three')%regex.match('four')%regex.match('five')%regex.match('six')%regex.match('seven')"
+       result_string := "%regex.match(0)%regex.match('one')%regex.match('two')%regex.match('three')%regex.match('four')%regex.match('five')%regex.match('six')%regex.match('seven')"
        if (!(result_string == '1_1')) {
                test_fail
        }
@@ -66,7 +66,7 @@ else {
 
 # Checking capture groups are cleared out correctly when there are no matches
 if (User-Name =~ /^.%{dummy_string}/) {
-       result_string := "%{0}%regex.match('one')%regex.match('two')%regex.match('three')%regex.match('four')%regex.match('five')%regex.match('six')%regex.match('seven')"
+       result_string := "%regex.match(0)%regex.match('one')%regex.match('two')%regex.match('three')%regex.match('four')%regex.match('five')%regex.match('six')%regex.match('seven')"
        if (!(result_string == '1')) {
                test_fail
        }
@@ -77,7 +77,7 @@ else {
 
 # compiled - ref - named capture groups
 if (User-Name =~ /^(?<one>[0-9])_(?<two>[0-9])?_(?<three>[0-9]*)_(?<four>[0-9]+)_(?<five>[^_])_(?<six>6)_(?<seven>[7-8])/) {
-       result_string := "%regex.match('seven')_%regex.match('six')_%regex.match('five')_%regex.match('four')_%regex.match('three')_%regex.match('two')_%regex.match('one')_%{0}"
+       result_string := "%regex.match('seven')_%regex.match('six')_%regex.match('five')_%regex.match('four')_%regex.match('three')_%regex.match('two')_%regex.match('one')_%regex.match(0)"
        if (!(result_string == '7_6_5_4_3_2_1_1_2_3_4_5_6_7')) {
                test_fail
        }
@@ -88,7 +88,7 @@ else {
 
 # compiled - xlat - named capture groups
 if ('1_2_3_4_5_6_7' =~ /^(?<one>[0-9])_(?<two>[0-9])?_(?<three>[0-9]*)_(?<four>[0-9]+)_(?<five>[^_])_(?<six>6)_(?<seven>[7-8])/) {
-       result_string := "%regex.match('seven')_%regex.match('six')_%regex.match('five')_%regex.match('four')_%regex.match('three')_%regex.match('two')_%regex.match('one')_%{0}"
+       result_string := "%regex.match('seven')_%regex.match('six')_%regex.match('five')_%regex.match('four')_%regex.match('three')_%regex.match('two')_%regex.match('one')_%regex.match(0)"
        if (!(result_string == '7_6_5_4_3_2_1_1_2_3_4_5_6_7')) {
                test_fail
        }
@@ -99,7 +99,7 @@ else {
 
 # compiled - ref - named capture groups (numeric indexes)
 if (User-Name =~ /^(?<one>[0-9])_(?<two>[0-9])?_(?<three>[0-9]*)_(?<four>[0-9]+)_(?<five>[^_])_(?<six>6)_(?<seven>[7-8])/) {
-       result_string := "%{7}_%{6}_%{5}_%{4}_%{3}_%{2}_%{1}_%{0}"
+       result_string := "%regex.match(7)_%regex.match(6)_%regex.match(5)_%regex.match(4)_%regex.match(3)_%regex.match(2)_%regex.match(1)_%regex.match(0)"
        if (!(result_string == '7_6_5_4_3_2_1_1_2_3_4_5_6_7')) {
                test_fail
        }
index a54008dfbd355320e954b6f60ecf6286f2441bf0..425fe4ed3752eea3fce06c90bfbd85538e5c0976 100644 (file)
@@ -6,7 +6,7 @@ Vendor-Specific.Cisco.AVPair := { 'foo=bar', 'bar=baz', 'baz=foo' }
 
 
 if (Vendor-Specific.Cisco.AVPair[1] =~ /bar=(.*)/) {
-       if (!("%{1}" == 'baz')) {
+       if (!("%regex.match(1)" == 'baz')) {
                test_fail
        }
 }
@@ -15,7 +15,7 @@ else {
 }
 
 if (Vendor-Specific.Cisco.AVPair[*] =~ /bar=(.*)/) {
-       if (!("%{1}" == 'baz')) {
+       if (!("%regex.match(1)" == 'baz')) {
                test_fail
        }
 }
index 6dee323f0dd7feb2724bf032952ae1ed1c1ea795..b1f67fd1b767a5a384ce0a138c47007c327aff35 100644 (file)
@@ -85,7 +85,7 @@ if !("0x%hex(%{test_octets})" =~ /^0x([0-9a-f]+)$/) {
        test_fail
 }
 
-result_string := "%{1}"
+result_string := "%regex.match(1)"
 
 if (!(%length(%{result_string}) == 8166)) {
        test_fail
index ef5ea2dbdd3ca795623a8fb9314f808d16631778..f7962f8d9db0dc5c04336cf612688ed499300f84 100644 (file)
@@ -21,13 +21,13 @@ if (!(%debug(%{test_integer}) == "%{test_integer}")) {
 "%{control.User-Name || control.Password.Cleartext}"
 
 if (control.Password.Cleartext =~ /(h)(e)(l)(l)(o)/) {
-       "%{0}"
-       "%{1}"
-       "%{2}"
-       "%{3}"
-       "%{4}"
-       "%{5}"
-       "%{6}"
+       "%regex.match(0)"
+       "%regex.match(1)"
+       "%regex.match(2)"
+       "%regex.match(3)"
+       "%regex.match(4)"
+       "%regex.match(5)"
+       "%regex.match(6)"
 }
 
 success
index 75effe3fcdc4e8b11f29755cf3a333b34739a42f..8a0fab0c8e843beee35a8e9c2c6716c319ba1ff1 100644 (file)
@@ -162,7 +162,7 @@ server test {
                #  so we can check the output
                #
                if (&LDAP-Sync.Entry-DN =~ /(CN=.+:)[a-f0-9-]+(,CN=Deleted Objects,DC=example,DC=com)/) {
-                       request.LDAP-Sync.Entry-DN := "%{1}oldid%{2}"
+                       request.LDAP-Sync.Entry-DN := "%regex.match(1)oldid%regex.match(2)"
                }
                linelog
        }
index aa8ab67b63a8c91274d316a89b4505c47aa17c4e..9b52a534da18cc88a92865546ae0e95b74da2093 100644 (file)
@@ -50,7 +50,7 @@ if (result_string != User-Name) {
 #
 if (User-Name =~ /^[0-9](.*)/) {
        request += {
-               User-Name = %{1}
+               User-Name = %regex.match(1)
                EAP-Type = ::AKA
        }
 }
index bbaeb36f5bb70bf9aa26ea6f5e77b3d496e9ee0d..0b715399a1b6fe3a006ba85a0743a43b539141a5 100644 (file)
@@ -21,7 +21,7 @@ control.User-Name := %3gpp_temporary_id.encrypt(%{User-Name},%{test_string},6)
 result_string := %3gpp_temporary_id.decrypt(%{control.User-Name}, %{test_string}, 'false')
 
 if ("%{User-Name}" =~ /^0(.*)/) {
-       if (!result_string || (result_string == '') || (%{result_string} != "%{1}")) {
+       if (!result_string || (result_string == '') || (%{result_string} != "%regex.match(1)")) {
                test_fail
        }
 }
index ba4994ec5c3cf6dddeb9081c0f01baa5e767e858..4ff332a00405c9bd96297cec8440d3833958a18d 100644 (file)
@@ -46,7 +46,7 @@ if !(reply.Session-Timeout == 100) {
 date_str = %date('now')
 now = %date(%{date_str})
 if (date_str =~ /([0-9]{4}-[0-9]{2}-[0-9]{2}T)[0-9]{2}:[0-9]{2}:[0-9]{2}Z/) {
-       date_str := "%{1}" + '00:00:00Z'
+       date_str := "%regex.match(1)" + '00:00:00Z'
 }
 start = %date(%{date_str})
 
index e8a878b71d30fa4beeaed05a85c0925677d18430..19b6ec9c489dfd6c122af1e3465e143685184bd5 100644 (file)
@@ -148,8 +148,8 @@ match %cast(uint32, Service-Type)
 xlat_expr 5 + ()
 match ERROR offset 6: Empty expressions are invalid
 
-xlat_expr %{3}
-match %{3}
+xlat_expr %regex.match(3)
+match %regex.match(3)
 
 #
 #  These next two are arguably wrong.
index f126064366f8cfc84c1bb5cf5985c5827ef34040..298f89b0160729f8c8b18210dfc882425697e3ab 100644 (file)
@@ -45,7 +45,7 @@ xlat_purify (2 + 3) * 4 + 5
 match 25
 
 #
-#  Not the same as a regex %{3}, but we can't tell the difference here.
+#  Not the same as a regex %{1}, but we can't tell the difference here.
 #
 xlat_purify %{1 + 2}
 match 3