From: Alan T. DeKok Date: Sun, 21 Aug 2022 14:03:51 +0000 (-0400) Subject: convert xlat-string to the new method X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b25ba32b43831236ff3756ebeb1a70f1931885e;p=thirdparty%2Ffreeradius-server.git convert xlat-string to the new method Previously "cast to string" was "print to string" for everything except octets. For octets, it was "cast". That inconsistency causes issues. Now, "cast to string" is "print to string" for everything. If the user wants to *convert* data to a string, the %{string:...} function can be used. --- diff --git a/src/tests/keywords/all.mk b/src/tests/keywords/all.mk index d5d9391fab6..7488cf4534b 100644 --- a/src/tests/keywords/all.mk +++ b/src/tests/keywords/all.mk @@ -41,7 +41,7 @@ test.keywords.${1}: $(addprefix $(OUTPUT)/,${1}) # Migration support. Some of the tests don't run under the new # conditions, so we don't run them under the new conditions. # -ifeq "$(findstring ${1}, paircmp xlat-string xlat-subst if-failed-xlat if-regex-match-comp if-regex-match-named)" "" +ifeq "$(findstring ${1}, paircmp xlat-subst if-failed-xlat if-regex-match-comp if-regex-match-named)" "" $(OUTPUT)/${1}: NEW_COND=-S parse_new_conditions=yes -S use_new_conditions=yes endif diff --git a/src/tests/keywords/xlat-string b/src/tests/keywords/xlat-string index f4dd84fb30c..d493ec3198a 100644 --- a/src/tests/keywords/xlat-string +++ b/src/tests/keywords/xlat-string @@ -1,37 +1,35 @@ # # PRE: update if # -# Remove all attributes in a list -# -update request { - &Tmp-Octets-0 := 0x5c5c - &Tmp-Octets-1 := 0x49206c696b6520636869636b656e2049206c696b65206c69766572 - &Tmp-Octets-2 := 0x490049 - &Tmp-Octets-3 := 0x00 - &Tmp-Octets-4 := 0x7465737431 - &Tmp-Octets-5 := 0x7465737432 -} - -update request { - &Tmp-String-0 := "%{string:%{Tmp-Octets-0}}" - &Tmp-String-1 := "%{string:%{Tmp-Octets-1}}" - &Tmp-String-2 := "%{string:%{Tmp-Octets-2}}" - &Tmp-String-3 := "%{string:%{Tmp-Octets-3}}" +&request += { + &Tmp-Octets-0 = 0x5c5c + &Tmp-Octets-1 = 0x49206c696b6520636869636b656e2049206c696b65206c69766572 + &Tmp-Octets-2 = 0x490049 + &Tmp-Octets-3 = 0x00 + &Tmp-Octets-4 = 0x7465737431 + &Tmp-Octets-5 = 0x7465737432 } -if (&Tmp-Octets-0 != &Tmp-String-0) { - test_fail -} - -if (&Tmp-Octets-1 != &Tmp-String-1) { - test_fail +&request += { + &Tmp-String-0 = "%{string:%{Tmp-Octets-0}}" + &Tmp-String-1 = "%{string:%{Tmp-Octets-1}}" + &Tmp-String-2 = "%{string:%{Tmp-Octets-2}}" + &Tmp-String-3 = "%{string:%{Tmp-Octets-3}}" } -if (&Tmp-Octets-2 != &Tmp-String-2) { +# +# Cast of octets to string is the octets *printed* to a string, just +# like every other data type. If we want to *convert* the octets to +# a string, we have to use "%{string:...}" +# +if (&Tmp-Octets-0 != "0x5c5c") { test_fail } -if (&Tmp-Octets-3 != &Tmp-String-3) { +# +# And the printed "0x5c5c" is not equivalent to the octet string +# +if (&Tmp-Octets-0 == 0x5c5c) { test_fail } @@ -39,7 +37,10 @@ if (&Tmp-String-0 != "\\\\") { test_fail } -if (&Tmp-Octets-0 != "%{string:%{Tmp-Octets-0}}") { +# +# These are now defined to be different. +# +if (&Tmp-Octets-0 == "%{string:%{Tmp-Octets-0}}") { test_fail }