Escaping control characters
This commit is contained in:
parent
89f8e2a79a
commit
637dfbf90a
@ -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("<node>", escape_text"<node>")
|
||||
|
||||
local attrs = {}
|
||||
local function write_elem(tree, indent)
|
||||
|
Loading…
Reference in New Issue
Block a user