pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36948?usp=email )
Change subject: asterisk: AMI_Functions: Fix decoding of empty AccountID field ......................................................................
asterisk: AMI_Functions: Fix decoding of empty AccountID field
While at it, convert the code to a loop since we start to have a bunch of fields to check.
Change-Id: Ifc0e84a81b24d8ce8194b769a8ff9a0d4f3e85ff --- M asterisk/AMI_Functions.ttcn 1 file changed, 17 insertions(+), 7 deletions(-)
Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified osmith: Looks good to me, but someone else must approve
diff --git a/asterisk/AMI_Functions.ttcn b/asterisk/AMI_Functions.ttcn index a82af97..9c84d00 100644 --- a/asterisk/AMI_Functions.ttcn +++ b/asterisk/AMI_Functions.ttcn @@ -419,13 +419,11 @@ private function dec_AMI_Msg_ext(charstring txt) return AMI_Msg { log("AMI dec: '", txt, "'"); /* TEXT Enc/dec is not happy with empty values, workaround it: */ - var charstring patched_txt := f_str_replace(txt, "Challenge: \r\n", ""); - patched_txt := f_str_replace(patched_txt, "AccountCode: \r\n", ""); - patched_txt := f_str_replace(patched_txt, "Value: \r\n", ""); - patched_txt := f_str_replace(patched_txt, "DestExten: \r\n", ""); - patched_txt := f_str_replace(patched_txt, "Exten: \r\n", ""); - patched_txt := f_str_replace(patched_txt, "Extension: \r\n", ""); - patched_txt := f_str_replace(patched_txt, "Hint: \r\n", ""); + var Misc_Helpers.ro_charstring fields := { "AccountCode", "AccountID", "Challenge", "DestExten", "Exten", "Extension", "Hint", "Value" }; + var charstring patched_txt := txt; + for (var integer i := 0; i < lengthof(fields); i := i +1) { + patched_txt := f_str_replace(patched_txt, fields[i] & ": \r\n", ""); + }
/* "AppData" field sometimes has a value containing separator ": ", which makes * TEXT dec not happy. Workaround it for now by removing the whole field line: