Artifact ee4d50abb4fe4d7731884f86e9f76a5a5645f634a42ec94cd3cad1dc45f9b8b4:
- File html.t — part of check-in [d228cd7fcb] at 2020-12-28 23:42:22 on branch trunk — vastly improve the setup process (user: lexi, size: 413) [annotate] [blame] [check-ins using]
-- vim: ft=terra
local m={}
local pstr = lib.mem.ptr(int8)
terra m.sanitize(txt: pstr, quo: bool)
var a: lib.str.acc a:init(txt.ct*1.3)
for i=0,txt.ct do
if txt(i) == @'<' then a:lpush('<')
elseif txt(i) == @'>' then a:lpush('>')
elseif txt(i) == @'&' then a:lpush('&')
elseif quo and txt(i) == @'"' then a:lpush('"')
else a:push(&txt(i),1) end
end
return a:finalize()
end
return m