From 77d332d4e3e3ed3d23f5e12d38666440c8d223a6 Mon Sep 17 00:00:00 2001 From: Mauro Iazzi Date: Fri, 16 May 2008 17:32:46 +0200 Subject: [PATCH] strip html escapes from text too --- new/xml.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/new/xml.lua b/new/xml.lua index a7cb375..5d96244 100644 --- a/new/xml.lua +++ b/new/xml.lua @@ -1,10 +1,14 @@ #!/usr/bin/lua -local parseargs, collect, strip_escapes +local parseargs, collect -strip_escapes = function (s) - s = string.gsub(s, '>', '>') - s = string.gsub(s, '<', '<') +local escapes = { + gt = '>', + lt = '<', +} + +local strip_escapes = function (s) + s = string.gsub(s, '&(%a+);', escapes) return s end @@ -29,7 +33,7 @@ function collect(s) if not ni then break end local text = string.sub(s, i, ni-1) if not string.find(text, "^%s*$") then - table.insert(top, text) + table.insert(top, strip_escapes(text)) end if empty == "/" then -- empty element tag table.insert(top, {label=label, xarg=parseargs(xarg), empty=1}) -- 2.11.4.GIT