summaryrefslogtreecommitdiff
path: root/scripts/context/lua/mtxrun.lua
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/context/lua/mtxrun.lua')
-rw-r--r--scripts/context/lua/mtxrun.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index 87d5c4460..8f098c1e3 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -7441,7 +7441,7 @@ local grammar_unparsed_text = P { "preamble",
-- maybe we will add settings to result as well
-local function xmlconvert(data, settings)
+local function _xmlconvert_(data, settings)
settings = settings or { } -- no_root strip_cm_and_dt given_entities parent_root error_handler
--
strip = settings.strip_cm_and_dt
@@ -7537,6 +7537,18 @@ local function xmlconvert(data, settings)
return result
end
+-- Because we can have a crash (stack issues) with faulty xml, we wrap this one
+-- in a protector:
+
+function xmlconvert(data,settings)
+ local ok, result = pcall(function() return _xmlconvert_(data,settings) end)
+ if ok then
+ return result
+ else
+ return _xmlconvert_("")
+ end
+end
+
xml.convert = xmlconvert
function xml.inheritedconvert(data,xmldata) -- xmldata is parent