From ac0f62030275b75ff87a4c8d526a7465da148208 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Fri, 4 Mar 2016 12:35:37 -0700 Subject: [PATCH] Prevent a nil error for xml handler languages. --- .../resources/scripts/languages/languages.lua | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua b/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua index 44bda18a1a..7316da0eb3 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/languages/languages.lua @@ -143,19 +143,21 @@ end --read root xml language file, parse included xml files - local xml_file_paths = {} - local file_handle = io.open(phrases_dir.."/"..language.."/"..language..".xml", "r"); - if (file_handle ~= nil) then - for file_line in file_handle:lines() do - if (string.find(file_line, 'cmd="include" data="', 0, true) ~= nil) then - pos_beg = string.find(file_line, 'cmd="include" data="', 0, true) + 20; - pos_end = string.find(file_line, '"/>', 0, true) - 1; - xml_file_path = string.sub(file_line, pos_beg, pos_end); - table.insert(xml_file_paths, phrases_dir.."/"..language.."/"..xml_file_path); - --freeswitch.consoleLog("notice", "file path = "..xml_file_path.."\n"); + if (phrases_dir ~= nil) then + local xml_file_paths = {} + local file_handle = io.open(phrases_dir.."/"..language.."/"..language..".xml", "r"); + if (file_handle ~= nil) then + for file_line in file_handle:lines() do + if (string.find(file_line, 'cmd="include" data="', 0, true) ~= nil) then + pos_beg = string.find(file_line, 'cmd="include" data="', 0, true) + 20; + pos_end = string.find(file_line, '"/>', 0, true) - 1; + xml_file_path = string.sub(file_line, pos_beg, pos_end); + table.insert(xml_file_paths, phrases_dir.."/"..language.."/"..xml_file_path); + --freeswitch.consoleLog("notice", "file path = "..xml_file_path.."\n"); + end end + file_handle:close(); end - file_handle:close(); end --iterate array of file paths, get contents of other xml macro files