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
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: