diff --git a/luamml-xmlwriter.lua b/luamml-xmlwriter.lua index cbdc1f1..47d4385 100644 --- a/luamml-xmlwriter.lua +++ b/luamml-xmlwriter.lua @@ -10,8 +10,11 @@ local escapes = { ['&'] = "&", } local function escape_text(text) - return string.gsub(tostring(text), '["<>&]', escapes) + return string.gsub(string.gsub(tostring(text), '["<>&]', escapes), '[\x00-\x08\x0B\x0C\x0E-\x20]', function(x) + return string.format('^^%02x', string.byte(x)) + end) end +print("", escape_text"") local attrs = {} local function write_elem(tree, indent)