File html.t artifact ee4d50abb4 part of check-in 78b0198f09
-- 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